lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Sep 16, 2011, at 5:50 AM, Gaspard Bucher wrote:

After some more investigation, I think this is some edge case bug because I do not see what is wrong with the following pattern:

I found that the bug happens when the userdata has it's own environment and when this environment contains a lua_thread which in turn contains foobar:

   +-------- stack -------------------+
   | |
   v |
foobar ---> udata ---> fenv ---> udata_thread
              ^ |
              | |

The bug only appears when 'foobar' is in udata_thread's stack.

See the recent weak tables and finalization discussion, but I think this is another case of:

thread becomes unreachable
... so udata becomes unreachable
... so udata is queued for finalization
... so fenv and everything it leads to is marked in case it's needed for finalization
... so udata_thread gets marked
... so the code to clear weak tables keeps the thread around in your weak table (not shown) for another cycle

Then eventually, we finalize udata and bingo we have a path to a finalized userdatum.

The other discussion was moving toward a suggestion that the logic for clearing weak tables needed to be moved in the GC process.