[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lua51w4-rvm segmentation fault
- From: Mike Pall <mikelu-0502@...>
- Date: Wed, 16 Feb 2005 13:43:56 +0100
> I have the suspicion that this is a crash in one of your loaded modules
> because the base address differs so much from the Lua core addresses.
Uh oh ... I think I know what is happening (but this is a bit guesswork):
It crashes when the state is closed in the final step of lua_close()
when all GC methods are run. But the address that the particular
GC method refers to is no longer mapped. I.e. it must have been some
GC method of a userdata object created by a module.
The only circumstance where this can happen is if the GC method of the
module handle was used to unmap the library (a new feature since 51w3!).
You'll get a crash if the module GC method is run *before* any GC methods
of objects created by this module. Ouch!
Yes, I guess this is a bug in the Lua core. We need to ensure that the
GC methods of the module handles are run *last*. Alas, there is no such
Does this analysis make sense?
The 'quick' solution is to rip out module unloading (ugh).
The 'real' solution would be to use Edgar Toernig's idea of tagging
every closure with the module where it is loaded from and get 'true' GC
(runtime, not just at close) for loaded modules. This ensures that the
GC method of the module runs last (because it is still marked when
there is any live userdata GC method (a closure) for the module).