GNOME Bugzilla – Bug 760680
Emitting "shutdown" signal twice leads to a crash
Last modified: 2016-01-18 17:38:14 UTC
It would be very nice if the GtkApplication was smart enough and didn't crash when one emits a "shutdown" signal multiple times (I did't try to emit "startup" twice, it may cause a leak or something, probably). It leads to a crash due to absolutely no code safe checks. The checks would not help to the core of the issue, because the problem would still be in the gtk+, but it would only print runtime warnings, instead of crashing (due to dereferencing a NULL pointer) whole application.
not clear to me what exactly the complaint is. The shutdown signal is emitted in exactly one place, in g_application_run in GApplication. How do you managed to have it emitted more than once ?
I do it manually, due to bug #737949. And as it's a signal, anybody can emit it (generally speaking). Ideally, the GtkApplication code should be robust, you never know what the users of the library will do.
if you're manually emitting signals on an object you don't own, you own all the pieces afterwards... just because it is a signal does not mean that you're ok to just emit it yourself.
Well, *you* told me to emit it to avoid memory leak (bug #737949 comment #3); now *you* tell me to not emit it. E? Anyway, it doesn't change anything on the fact that it's too easy to crash any GtkApplication, only because it (and GApplication) is not robust enough to check passed-in arguments and avoid NULL dereferences. That's the only thing about this bug report, write the code cleanly and avoid crashes. That's why g_return_if_fail() and its variants exists, isn't it? I do not understand why there is so much noise about web pages being able to crash a browser, when the core of the browser can be easily crashed due to libraries it uses (yeah, I compare web pages/browsers with Gtk/GApplication-s).
yeah, sorry. Anyway I pushed a fix to avoid the crash
Thanks.