crash at program termination after using gtk native file chooser
Opened this issue · 4 comments
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)
.
I experience the problem on Ubuntu 16.04, too. I also see the following error message on the command line:
/usr/share/themes/Radiant-MATE/gtk-2.0/apps/mate-panel.rc:30: error: invalid string constant "scrollbar", expected valid string constant
It is generated in the Fl_Native_File_Chooser::show()
method call, that however does not return -1 as it should do on error. I suspect a memory corruption around there because if fnfc:show()
is commented out in the example, the program doesn't crash (at least on my PC).
Tomorrow I'll investigate further.
The problem with Fl_Native_File_Chooser::show()
seems to be another problem. However both cases show that the NativeGTKFileChooser functionality is a little bit problematic.
Under current Manjaro the GTK filechooser is correctly shown. The crash here happens at program exit when the Lua state is closed and frees all shared object (native lua modules). The crash happens only at program exit when die GTK file chooser was invoked. If the GTK file chooser was not invoked, program termination is OK. The problematic call is in Fl_Native_File_Chooser_GTK.cxx
the call to fl_gtk_init_check
(which in fact calls gtk_init_check
in the loaded gtk shared object). This call is enough to trigger the crash at program exit. So the rest of the file chooser is not relevant for this problem. It's the GTK lib iniatialisation in general.
Best regards,
Oliver
I see... and fl_gtk_init_check
is called from within the show
method, that's why if I comment it out the program doesn't crash.
Not closing the Lua state causes memory leaks, which should not be a great deal on most system. Can we live with it, for now?
Yes, I think it's not a real problem, it's only a problem for ending the application and therefore memory leaks are not a real problem. We should adjust the examples to call os.exit()
instead of os.exit(true, true)
.