lua-users home
lua-l archive

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


> OS X 10.5.3, i686-apple-darwin9-gcc-4.0.1, gdb 6.3.50-20050815
> Lua 5.1.3 with several third-party modules, all built as C++.
> 
> In my application after Lua error I sometimes (in roughly one of five
> runs) get a segfault on lua_close() in module unload.
> 
> Lua-related part of the stack trace:
> 
> #0  0x8fe1d10a in __dyld_munmap$UNIX2003 ()
> #1  0x8fe13a03 in __dyld__ZN16ImageLoaderMachOD0Ev ()
> #2  0x8fe03206 in __dyld__ZN4dyld20garbageCollectImagesEv ()
> #3  0x8fe0bd46 in __dyld_dlclose ()
> #4  0x97197bae in dlclose ()
> #5  0x00fcbcdf in gctm (L=0x0) at src/loadlib.c:64
> #6  0x00fc2bdf in luaD_precall (L=0x1228d80, func=0x18cf20c,
> nresults=0) at src/ldo.c:319
> #7  0x00fc3173 in luaD_call (L=0x1209f00, func=0x18cf20c, nResults=0)
> at src/ldo.c:376
> #8  0x00fc5766 in GCTM (L=0x1209f00) at src/lgc.c:467
> #9  0x00fc57e8 in luaC_callGCTM (L=0x1209f00) at src/lgc.c:479
> #10 0x00fc1a8a in luaD_rawrunprotected (L=0x1209f00, f=0xfd2900
> <callallgcTM>, ud=0x0) at src/ldo.c:116
> #11 0x00fd298e in lua_close (L=0x1209f00) at src/lstate.c:205
> 
> If I build Lua and my application with -DLUA_USE_APICHECK and
> -Dlua_assert=assert I still get the same segfault. I have checked my
> application against multiple links to lua shared library, and found
> nothing.
> 
> I'd like to know at least which module crashes. Any advice on the best
> way to get this info?

By "which module" you mean what C module it is dl-closing when it
crashes? Lua closes these modules in the reverse order that they were
created. So, if you print the module name at each call to ll_load, then
you will know what each call to ll_unloadlib is closing. (BTW, there
are some strange things in your trace that may be caused by some
optimizations. In entry #5, loadlib.c:64 is function ll_unloadlib,
not gctm, and there is no argument 'L' there...)

-- Roberto