Failure in gjs_callback_closure() causes gnome-shell to incorrectly exit(1)
There is a bug, I'm thinking in GJS, causing gnome-shell to exit(EXIT_FAILURE) (thus without causing a core dump and probably invisible in distro crash logs). I can reproduce it by, from within gnome-shell do:
- Press Super+L (to lock)
- Hit Esc
- Goto 2
After a few times gnome-shell will exit without any trace of crash or suggestion where to start looking for what happened. After some suspicious log entries I thought it could be gdm related, but after some digging with @halfline we concluded that gnome-shell for some reason calls exit(1). I added a on_exit(if (exit_status == 1) abort()) in gnome-shell, which showed me that the exit(1) call was this one in gi/functions.cpp
. It was invoked from a D-Bus message reply GTask.
After some digging, we end up there because of the gjs_value_from_g_argument()
call under the PARAM_NORMAL
case is failing for some reason. After that I enabled various gjs debug log stuff, which I'm attaching here: gjs.debuglog. I didn't investigate further than that.
A side note: wouldn't it make sense to change those exit(1)'s to g_error() to actually catch those errors?
Another side note: I used the following diff on mutter to catch the "crash":
diff --git a/src/core/main.c b/src/core/main.c
index dc1f1c4f6..19e74e790 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -494,6 +494,14 @@ meta_override_compositor_configuration (MetaCompositorType compositor_type,
_backend_gtype_override = backend_gtype;
}
+static void
+abort_on_exit_failure (int retval,
+ void *user_data)
+{
+ if (retval != 0)
+ g_error ("Something caused the program to exit with failure");
+}
+
/**
* meta_init: (skip)
*
@@ -508,6 +516,8 @@ meta_init (void)
MetaCompositorType compositor_type;
GType backend_gtype;
+ on_exit (abort_on_exit_failure, NULL);
+
sigemptyset (&empty_mask);
act.sa_handler = SIG_IGN;
act.sa_mask = empty_mask;