-
Notifications
You must be signed in to change notification settings - Fork 9
Description
In the example editor.lua the program is terminated with os.exit(true, true). This leads to a crash after the gtk native file chooser was invoked (at least under current Manjaro Linux, latest release MoonFLTK 0.5 und also current git master), stacktrace:
#0 0x00007f510e851bc5 in getenv () at /usr/lib/libc.so.6
#1 0x00007f5105a0b4b0 in () at /usr/lib/libcanberra.so.0
#2 0x00007f510f587af3 in _dl_fini () at /lib64/ld-linux-x86-64.so.2
#3 0x00007f510e852448 in __run_exit_handlers () at /usr/lib/libc.so.6
#4 0x00007f510e85249a in () at /usr/lib/libc.so.6
#5 0x0000562b55393741 in os_exit (L=0x562b56989268) at loslib.c:379
The program does not crash if terminating with os.exit(true, false) or if the FLTK file chooser is used instead of the GTK one.
The problem is, that the second true argument in os.exit leads to closing the lua_State before the exit handlers are called. In lua source loadlib.c one can see that closing the lua state unloads all native shared objects, e.g. moonfltk.so. Unloading moonfltk.so seems to unload some other shared objects that are needed by another exit handler: if the call to dlclose in lua/loadlib.c is commented out, than no crash does occur.
I did not find a better solution than just quitting the application with os.exit(true, false).