lua-users home
lua-l archive

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


Hi there,

I think it would be very valuable to have a comment on finalizers and what can be done in these in the reference manual. I lost a day's work struggling with gdb to discover that calling any method from "C" from a finalizer is a bad idea (crash).

Something like this would have helped:

29 – Managing Resources 
Life is not always that easy. [...]. This function can then release any resource associated with that userdatum but it should not call a C function from Lua.

Or maybe the rule is slightly more complex. In my case, the crash happens with:

Lua GC ---> Foobar::finalizer (custom C++ finalizer) --> pcall --> call C function

Cheers !


                                                               Gaspard