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 789223 - gnome-shell crashes in meta_plugin_manager_event_simple when no plugin manager is set (yet?)
gnome-shell crashes in meta_plugin_manager_event_simple when no plugin manage...
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: general
3.26.x
Other Linux
: Normal normal
: ---
Assigned To: mutter-maint
mutter-maint
Depends on:
Blocks:
 
 
Reported: 2017-10-20 01:09 UTC by Marco Trevisan (Treviño)
Modified: 2017-10-24 09:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
MetaPluginManager: ensure we deference a valid pointer when processing events (1.37 KB, patch)
2017-10-20 01:14 UTC, Marco Trevisan (Treviño)
none Details | Review
MetaPluginManager: don't try to deference a NULL pointer when processing events (1.57 KB, patch)
2017-10-20 05:09 UTC, Marco Trevisan (Treviño)
none Details | Review
MetaWindowActor: don't start any effect when no compositor is available (1.06 KB, patch)
2017-10-20 07:52 UTC, Marco Trevisan (Treviño)
none Details | Review
MetaWindowActor: don't start any effect when no compositor is available (1.14 KB, patch)
2017-10-24 08:12 UTC, Marco Trevisan (Treviño)
committed Details | Review

Description Marco Trevisan (Treviño) 2017-10-20 01:09:51 UTC
This issue seems to be around in both Ubuntu (https://pad.lv/1725068) and redhat (https://bugzilla.redhat.com/show_bug.cgi?id=1452914) bug trackers.

Stacktrace is:

  • #0 meta_plugin_manager_event_simple
    at compositor/meta-plugin-manager.c line 158
  • #1 start_simple_effect
    at compositor/meta-window-actor.c line 1103
  • #2 meta_window_actor_show
    at compositor/meta-window-actor.c line 1329
  • #3 meta_compositor_show_window
    at compositor/compositor.c line 786
  • #4 meta_window_show
    at core/window.c line 2474
  • #5 implement_showing
    at core/window.c line 1714
  • #6 idle_calc_showing
    at core/window.c line 1822
  • #7 run_repaint_laters
    at core/util.c line 809
  • #8 run_all_repaint_laters
    at core/util.c line 826
  • #9 _clutter_run_repaint_functions
    at clutter-main.c line 3433
  • #10 master_clock_update_stages
    at clutter-master-clock-default.c line 437
  • #11 clutter_clock_dispatch
    at clutter-master-clock-default.c line 567
  • #12 g_main_dispatch
    at ../../../../glib/gmain.c line 3148
  • #13 g_main_context_dispatch
    at ../../../../glib/gmain.c line 3813
  • #14 g_main_context_iterate
    at ../../../../glib/gmain.c line 3886
  • #15 g_main_loop_run
    at ../../../../glib/gmain.c line 4082
  • #16 ffi_call_unix64
    at ../src/x86/unix64.S line 76
  • #17 ffi_call
    at ../src/x86/ffi64.c line 525
  • #18 gjs_invoke_c_function
    at gi/function.cpp line 1033
  • #19 function_call
    at gi/function.cpp line 1351
  • #20 js::CallJSNative
  • #21 js::InternalCallOrConstruct
    at ./js/src/vm/Interpreter.cpp line 447
  • #22 js::CallFromStack
    at ./js/src/vm/Interpreter.cpp line 510
  • #23 Interpret
    at ./js/src/vm/Interpreter.cpp line 2922
  • #24 js::RunScript
    at ./js/src/vm/Interpreter.cpp line 405
  • #25 js::InternalCallOrConstruct
    at ./js/src/vm/Interpreter.cpp line 477
  • #26 InternalCall
    at ./js/src/vm/Interpreter.cpp line 504
  • #27 js::Call
    at ./js/src/vm/Interpreter.cpp line 523
  • #28 js::fun_apply
    at ./js/src/jsfun.cpp line 1318
  • #29 js::CallJSNative
    at ./js/src/jscntxtinlines.h line 239
  • #30 js::InternalCallOrConstruct
    at ./js/src/vm/Interpreter.cpp line 459
  • #31 InternalCall
    at ./js/src/vm/Interpreter.cpp line 504
  • #32 js::CallFromStack
    at ./js/src/vm/Interpreter.cpp line 510
  • #33 js::jit::DoCallFallback
    at ./js/src/jit/BaselineIC.cpp line 6020

So basically, it's quite easy to see the crash and it probably happens because the compositor has not been managed yet...

So, fixing the crash can be quite easy, but just wondering...

Could this happen before the compositor is properly managed, and thus anticipating compositor->plugin_mgr = meta_plugin_manager_new (compositor); there could help, or just could happen that a window wants to be shown/hidden when no compositor is set yet?

In any case I think in this case is just sane to no do any effect and, better, not to crash.
Comment 1 Marco Trevisan (Treviño) 2017-10-20 01:14:06 UTC
Created attachment 361907 [details] [review]
MetaPluginManager: ensure we deference a valid pointer when processing events

Alternative to this is actually to just not calling meta_plugin_manager_event_simple in MetaWindow's start_simple_effect if the compositor is not managed, thus just applying the requested window transformation.
Up to you.
Comment 2 Jonas Ådahl 2017-10-20 02:49:24 UTC
Review of attachment 361907 [details] [review]:

::: src/compositor/meta-plugin-manager.c
@@ +159,3 @@
+  gboolean retval;
+
+  g_return_val_if_fail (plugin_mgr, FALSE);

This is just a debug-build-only soft-assert, which is fine I guess, but the commit message should reflect that. Calling this function with NULL makes no sense anyhow, and is an application bug, so I don't think we need to handle that more than this though.
Comment 3 Marco Trevisan (Treviño) 2017-10-20 05:09:27 UTC
Created attachment 361912 [details] [review]
MetaPluginManager: don't try to deference a NULL pointer when processing events

This function might be called by components with invalid plugin manager
(as it might happen to MetaWindow when the compositor isn't initialized
properly), so we need to protect ourselves from crashes.
Comment 4 Jonas Ådahl 2017-10-20 06:56:26 UTC
Review of attachment 361912 [details] [review]:

Hmm, so this function is not exposed outside of mutter, then it's not the right thing to handle invalid input here, as it'll just hide the actual error.

If the compositor isn't initialized properly, we should instead gracefully shut down without ever trying to start an effect (seems to be the only place this function is called from)
Comment 5 Marco Trevisan (Treviño) 2017-10-20 07:52:27 UTC
Created attachment 361917 [details] [review]
MetaWindowActor: don't start any effect when no compositor is available

There are cases when no compositor is available (yet) but a MetaWindow tries
to start a simple effect using a compositor plugin which is not available.
In that case we should just ignore any request and protect ourselves from
crashes.
Comment 6 Rui Matos 2017-10-20 09:01:58 UTC
I wonder what these cases are. Is this reproducible? What's the JS stack trace?
Comment 7 Jonas Ådahl 2017-10-20 09:10:29 UTC
Have discussed this issue a bit on IRC, and the only explanation I can think of is that an extension calls Mainloop.run() or something similar on startup, which happens to dispatch a clutter paint. We should not allow running the main loop from within JS this way, so we should rather catch the JS backtrace instead.

A way to maybe do this is to add a gjs_dumpstack() as a SIGABRT handler, and add an g_assert() instead of the g_return_val_if_fail() as added in one of the patches.
Comment 8 Marco Trevisan (Treviño) 2017-10-24 08:12:18 UTC
Created attachment 362153 [details] [review]
MetaWindowActor: don't start any effect when no compositor is available

As said, let's just assert now... The bad guys will be easier to find now
(as per changes of Bug 789237).
Comment 9 Jonas Ådahl 2017-10-24 09:06:59 UTC
Review of attachment 362153 [details] [review]:

commit message subject is incorrect. It should be something like

"MetaWindowActor: Assert that we have plugin manager on simple effect"

then explain that this is in order to catch bugs.

The current message makes it sound like we actually try to handle it sanely.

With that fixed, this lgtm.
Comment 10 Marco Trevisan (Treviño) 2017-10-24 09:45:32 UTC
The following fixes have been pushed:
https://git.gnome.org/browse/mutter/commit/?id=91e3a0b3