PLTools / Lama

Teaching language LaMa for a compiler course
GNU General Public License v3.0
67 stars 28 forks source link

Garbage collector failure #8

Closed bash-spbu closed 3 years ago

bash-spbu commented 4 years ago

Consider the following example:

fun bigValue() {
  local r = {};
  for local i; i := 0, i < 1000000, i := i + 1 do
    r := i : r
  od;
  r
}

for local i; i := 0, i < 10, i := i + 1 do
  bigValue()
od

It fails on my machine (Ubuntu 18.04) with segfault which is caused somewhere in runtime garbage collection part (because of looping and stackoverflow as I feel it). The begining of GDB backtrace:

#116428 0x56559d17 in gc_copy (obj=0xf7db9f7c) at runtime.c:1677
#116429 0x56559981 in copy_elements (where=0xe7dba06c, from=0xf7db9f8c, len=2) at runtime.c:1523
#116430 0x56559d17 in gc_copy (obj=0xf7db9f8c) at runtime.c:1677
#116431 0x56559981 in copy_elements (where=0xe7dba05c, from=0xf7db9f9c, len=2) at runtime.c:1523
#116432 0x56559d17 in gc_copy (obj=0xf7db9f9c) at runtime.c:1677
#116433 0x56559981 in copy_elements (where=0xe7dba04c, from=0xf7db9fac, len=2) at runtime.c:1523
#116434 0x56559d17 in gc_copy (obj=0xf7db9fac) at runtime.c:1677
#116435 0x56559981 in copy_elements (where=0xe7dba03c, from=0xf7db9fbc, len=2) at runtime.c:1523
#116436 0x56559d17 in gc_copy (obj=0xf7db9fbc) at runtime.c:1677
#116437 0x56559981 in copy_elements (where=0xe7dba02c, from=0xf7db9fcc, len=2) at runtime.c:1523
#116438 0x56559d17 in gc_copy (obj=0xf7db9fcc) at runtime.c:1677
#116439 0x56559981 in copy_elements (where=0xe7dba01c, from=0xf7db9fdc, len=2) at runtime.c:1523
#116440 0x56559d17 in gc_copy (obj=0xf7db9fdc) at runtime.c:1677
#116441 0x56559981 in copy_elements (where=0xe7dba00c, from=0xf7db9fec, len=2) at runtime.c:1523
#116442 0x56559d17 in gc_copy (obj=0xf7db9fec) at runtime.c:1677
#116443 0x56559daf in gc_test_and_copy_root (root=0xffffcea8) at runtime.c:1710
#116444 0x56555f16 in gc_run_t () at gc_runtime.s:102
#116445 0x00000001 in ?? ()
#116446 0x5655cf38 in _DYNAMIC ()
#116447 0xffffce08 in ?? ()
#116448 0x56559f7f in gc (size=4) at runtime.c:1767
#116449 0x5655a1ba in alloc (size=4) at runtime.c:1945
#116450 0x56558304 in Bsexp (bn=7) at runtime.c:1001
#116451 0x56555e51 in L30 () at tmp.s:277
#116452 0x00000007 in ?? ()
#116453 0x000bdbf9 in ?? ()
#116454 0xf7db9fec in ?? ()
#116455 0x56555dc0 in L7 () at tmp.s:150
#116456 0x00000011 in ?? ()
#116457 0x00000000 in ?? ()

Lamac version:

Version master, 7748144a8, Fri Apr 10 03:15:18 2020 +0300
dboulytchev commented 4 years ago

Since

ulimit -S -s 65534

solves the problem the reason is the recursive implementation of root tracing (or copying) in the GC. I'm not sure if we have to fix it right now. Can be set the stack size programmatically?

bash-spbu commented 4 years ago

For me personally this issue is not crucial though it may happen with other users couple of times. Anyway I will agree on any decision you take.