lua-users home
lua-l archive

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

Roberto Ierusalimschy wrote:
Yes, there is such mechanism. Lua ensures that GC methods are called in
the reverse order of the corresponding userdata creation. Therefore, as
long as a library was loaded before we start creating its userdata, it
should be unloaded only after all its userdata is finalized. The bug
is that Lua is not preserving that order when it closes its state.

Ed Ferguson found this bug a few weeks ago. Sorry I didn't send it to
the list (I thought it was a very rare situation). The following patch
in function luaC_separateudata (lgc.c) should fix it. (The line numbers
may be wrong, because I have made other changes to that file, but I hope
you can find the correct place.)

I'm sorry that what I'm about to say might be the worst bug
report in history, but here goes!

I'm having a problem where my objects seem to be getting GC'd in an
unexpected order at shutdown, in 5.1work5.  I'd previously seen this
problem in 5.1work4 and thought that it was fixed when I applied
Roberto's (or Ed Ferguson's) patch, but only one instance of it was

When I encountered and traced this problem in detail using 5.1w4 I
concluded that it had to be a Lua bug, but it might still be MY bug.
This is a big scary app so I don't really have any confidence that I
could reduce it to a testcase, but this is a heads-up for anyone
who was seeing a similar problem in w4 to re-test with their own app.

Adam D. Moss   -