Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash at program termination after using gtk native file chooser #6

Open
osch opened this issue Apr 1, 2018 · 4 comments
Open

crash at program termination after using gtk native file chooser #6

osch opened this issue Apr 1, 2018 · 4 comments
Labels

Comments

@osch
Copy link
Contributor

osch commented Apr 1, 2018

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).

@stetre stetre added the bug label Apr 1, 2018
@stetre
Copy link
Owner

stetre commented Apr 1, 2018

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.

@osch
Copy link
Contributor Author

osch commented Apr 1, 2018

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

@stetre
Copy link
Owner

stetre commented Apr 2, 2018

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?

@osch
Copy link
Contributor Author

osch commented Apr 2, 2018

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants