After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 760680 - Emitting "shutdown" signal twice leads to a crash
Emitting "shutdown" signal twice leads to a crash
Product: gtk+
Classification: Platform
Component: Class: GtkApplication
Other Linux
: Normal critical
: ---
Assigned To: gtkdev
Depends on:
Reported: 2016-01-15 15:07 UTC by Milan Crha
Modified: 2016-01-18 17:38 UTC
See Also:
GNOME target: ---
GNOME version: ---

Description Milan Crha 2016-01-15 15:07:25 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.
Comment 1 Matthias Clasen 2016-01-15 15:19:47 UTC
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 ?
Comment 2 Milan Crha 2016-01-15 15:40:21 UTC
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.
Comment 3 Matthias Clasen 2016-01-15 15:42:38 UTC
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.
Comment 4 Milan Crha 2016-01-18 10:29:24 UTC
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).
Comment 5 Matthias Clasen 2016-01-18 14:22:26 UTC
yeah, sorry. Anyway I pushed a fix to avoid the crash
Comment 6 Milan Crha 2016-01-18 17:38:14 UTC