Spivoxity / obc-3

Oxford Oberon-2 compiler
38 stars 7 forks source link

Garbage collector bug in bytecode interpreter #27

Closed Spivoxity closed 5 years ago

Spivoxity commented 5 years ago

In certain cases, typically involving syntactically nested function calls, the garbage collector fails to interpret pointer maps of the evaluation stack correctly when invoked from the bytecode interpreter. For example, the attached test case fails to print the expected result.

This does not affect programs running under the JIT translator, because pointer maps are treated with a different mechanism there.

(see tPow.m)

Found by Ed Carroll.

Spivoxity commented 5 years ago

traverse_stack() contains a loop that chains down the stack, and the loop body ends with assignments to pc and sp for use in the next frame. The bug was a continue statement that erroneously skipped these assignments if the frame contained no stack map table. The fix is to adopt a less convoluted control structure.

Fixed in trunk.