apoch / epoch-language

Home of the Epoch Programming Language Project
Other
72 stars 3 forks source link

Temporary expressions are prematurely garbage collected #82

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Consider the compound expression in the following statement:

debugwritestring("A: " ; cast(string, a) ; " B: " ; cast(string, b) ; " C: " ; 
cast(string, c))

If the garbage collector ticks over at the right time (say, after the call to 
cast b to a string) it will collect the temporary string objects being created 
as part of the expression, without properly noting that they are in use.

This is due to a limitation in the current garbage collector, wherein the stack 
is not fully examined - only local variables and registers and 
freestore-allocated structures. Temporary values on the stack are ignored, 
mainly because of a lack of type annotations indicating how to *interpret* 
stack values.

For example, consider the stack with two booleans, an int16, and an integer, 
which happen to map out to values that correspond to string handles. Should we 
flag those handles as in-use on the off-chance that the stack values correspond 
to strings? Or do we need type annotations someplace that will tell us to 
ignore all the values involved?

This will need to be carefully considered for a proper solution.

Original issue reported on code.google.com by don.ap...@gmail.com on 17 Dec 2010 at 9:42

GoogleCodeExporter commented 9 years ago
This is something of a fixed issue with the new JIT-based GC strategy.

Original comment by don.ap...@gmail.com on 11 Apr 2013 at 6:07