Possible bug in the garbage collector causing Blocks to be collected prematurely
There appears to be a bug in the garbage collector, or perhaps IVM's handling of tail calls, causing Blocks (and potentially other objects) to become collected/corrupted prematurely. This can be reproduced as follows:
def bug {
let mut number = 0
{ number < 1_000_000 }.while_true {
number += 1
[1.0, 2.0, 3.0]
}
}
bug
Running this on the ffi
branch (master
is most likely also affected) using env RUBYLIB=./compiler/lib ./compiler/bin/inko -i runtime/src/ --vm ./vm/target/release/ivm /tmp/bug.inko
will quite frequently (but not always) produce the following panic:
Stack trace (the most recent call comes last):
0: "/tmp/bug.inko", line 10, in "main"
1: "/tmp/bug.inko", line 4, in "bug"
2: "/home/yorickpeterse/Projects/inko/inko/runtime/src/std/block.inko", line 198, in "while_true"
Process 0 panicked: ObjectValue::as_block() called on a non block object
Edited by Yorick Peterse