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 791006 - Changing resolution/scale might lead to a crash when deferencing a destroyed compositor's top_window_actor
Changing resolution/scale might lead to a crash when deferencing a destroyed ...
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: wayland
3.27.x
Other Linux
: Normal normal
: ---
Assigned To: mutter-maint
mutter-maint
Depends on:
Blocks:
 
 
Reported: 2017-11-29 22:59 UTC by Marco Trevisan (Treviño)
Modified: 2017-12-01 03:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
compositor: add a weak-ref to nullify top_window_actor when it's removed (1.81 KB, patch)
2017-11-29 23:08 UTC, Marco Trevisan (Treviño)
none Details | Review
compositor: also remove actors from the windows list (1.08 KB, patch)
2017-11-30 19:09 UTC, Marco Trevisan (Treviño)
none Details | Review
compositor: reset top_window_actor and remove it from windows when destroyed (2.46 KB, patch)
2017-12-01 03:14 UTC, Marco Trevisan (Treviño)
committed Details | Review
window-actor: rename destroy function in maybe_destroy (2.09 KB, patch)
2017-12-01 03:17 UTC, Marco Trevisan (Treviño)
committed Details | Review

Description Marco Trevisan (Treviño) 2017-11-29 22:59:39 UTC
This happens repeatedly here when using the resource-scale branch and changing scale and resolution from u-c-c

The trace of the crash is:

  • #0 meta_window_actor_is_destroyed
    at /media/M2/GNOME/mutter/src/compositor/meta-window-actor.c line 911
  • #1 meta_window_actor_should_unredirect
    at /media/M2/GNOME/mutter/src/compositor/meta-window-actor.c line 1224
  • #2 meta_pre_paint_func
    at /media/M2/GNOME/mutter/src/compositor/compositor.c line 1110
  • #3 _clutter_run_repaint_functions
    at /media/M2/GNOME/mutter/clutter/clutter/clutter-main.c line 3450
  • #4 master_clock_update_stages
    at /media/M2/GNOME/mutter/clutter/clutter/clutter-master-clock-default.c line 437
  • #5 clutter_clock_dispatch
    at /media/M2/GNOME/mutter/clutter/clutter/clutter-master-clock-default.c line 567
  • #6 g_main_dispatch
    at /media/M2/GNOME/glib/glib/gmain.c line 3182
  • #7 g_main_context_dispatch
    at /media/M2/GNOME/glib/glib/gmain.c line 3847
  • #8 g_main_context_iterate
    at /media/M2/GNOME/glib/glib/gmain.c line 3920
  • #9 g_main_loop_run
    at /media/M2/GNOME/glib/glib/gmain.c line 4116
  • #10 meta_run
    at /media/M2/GNOME/mutter/src/core/main.c line 648
  • #11 main
    at ../../gnome-shell/src/main.c line 530
  • #0 meta_window_actor_finalize
    at /media/M2/GNOME/mutter/src/compositor/meta-window-actor.c line 508
  • #1 g_object_unref
    at /media/M2/GNOME/glib/gobject/gobject.c line 3330
  • #2 release_native_object
    at /media/M2/GNOME/gjs/gi/object.cpp line 1133
  • #3 object_instance_finalize
    at /media/M2/GNOME/gjs/gi/object.cpp line 1525
  • #4 js::Class::doFinalize
    at /media/M2/GNOME/_BUILD/mozjs-52.2.1gnome1/dist/include/js/Class.h line 816
  • #5 JSObject::finalize
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsobjinlines.h line 87
  • #6 js::gc::Arena::finalize<JSObject>
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 457
  • #7 FinalizeTypedArenas<JSObject>
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 515
  • #8 FinalizeArenas
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 549
  • #9 js::gc::ArenaLists::forceFinalizeNow
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 2732
  • #10 js::gc::ArenaLists::finalizeNow
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 2714
  • #11 js::gc::ArenaLists::queueForegroundObjectsForSweep
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 2850
  • #12 js::gc::GCRuntime::beginSweepingZoneGroup
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 5144
  • #13 js::gc::GCRuntime::beginSweepPhase
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 5232
  • #14 js::gc::GCRuntime::incrementalCollectSlice
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 5913
  • #15 js::gc::GCRuntime::gcCycle
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 6201
  • #16 js::gc::GCRuntime::collect
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 6329
  • #17 js::gc::GCRuntime::gc
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 6397
  • #18 JS_GC
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsapi.cpp line 1326
  • #19 gjs_gc_if_needed
    at /media/M2/GNOME/gjs/gjs/jsapi-util.cpp line 746
  • #20 trigger_gc_if_needed
    at /media/M2/GNOME/gjs/gjs/context.cpp line 425
  • #21 g_main_dispatch
    at /media/M2/GNOME/glib/glib/gmain.c line 3182
  • #22 g_main_context_dispatch
    at /media/M2/GNOME/glib/glib/gmain.c line 3847
  • #23 g_main_context_iterate
    at /media/M2/GNOME/glib/glib/gmain.c line 3920
  • #24 g_main_loop_run
    at /media/M2/GNOME/glib/glib/gmain.c line 4116
  • #25 meta_run
    at /media/M2/GNOME/mutter/src/core/main.c line 648
  • #26 main
    at ../../gnome-shell/src/main.c line 530
  • #0 meta_window_actor_finalize
    at /media/M2/GNOME/mutter/src/compositor/meta-window-actor.c line 508
  • #1 g_object_unref
    at /media/M2/GNOME/glib/gobject/gobject.c line 3330
  • #2 release_native_object
    at /media/M2/GNOME/gjs/gi/object.cpp line 1133
  • #3 object_instance_finalize
    at /media/M2/GNOME/gjs/gi/object.cpp line 1525
  • #4 js::Class::doFinalize
    at /media/M2/GNOME/_BUILD/mozjs-52.2.1gnome1/dist/include/js/Class.h line 816
  • #5 JSObject::finalize
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsobjinlines.h line 87
  • #6 js::gc::Arena::finalize<JSObject>
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 457
  • #7 FinalizeTypedArenas<JSObject>
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 515
  • #8 FinalizeArenas
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 549
  • #9 js::gc::ArenaLists::forceFinalizeNow
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 2732
  • #10 js::gc::ArenaLists::finalizeNow
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 2714
  • #11 js::gc::ArenaLists::queueForegroundObjectsForSweep
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 2850
  • #12 js::gc::GCRuntime::beginSweepingZoneGroup
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 5144
  • #13 js::gc::GCRuntime::beginSweepPhase
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 5232
  • #14 js::gc::GCRuntime::incrementalCollectSlice
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 5913
  • #15 js::gc::GCRuntime::gcCycle
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 6201
  • #16 js::gc::GCRuntime::collect
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 6329
  • #17 js::gc::GCRuntime::gc
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 6397
  • #18 JS_GC
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsapi.cpp line 1326
  • #19 gjs_gc_if_needed
    at /media/M2/GNOME/gjs/gjs/jsapi-util.cpp line 746
  • #20 trigger_gc_if_needed
    at /media/M2/GNOME/gjs/gjs/context.cpp line 425
  • #21 g_main_dispatch
    at /media/M2/GNOME/glib/glib/gmain.c line 3182
  • #22 g_main_context_dispatch
    at /media/M2/GNOME/glib/glib/gmain.c line 3847
  • #23 g_main_context_iterate
    at /media/M2/GNOME/glib/glib/gmain.c line 3920
  • #24 g_main_loop_run
    at /media/M2/GNOME/glib/glib/gmain.c line 4116
  • #25 meta_run
    at /media/M2/GNOME/mutter/src/core/main.c line 648
  • #26 main
    at ../../gnome-shell/src/main.c line 530


Look that this might be related to Bug 788493 too.
Comment 1 Marco Trevisan (Treviño) 2017-11-29 23:02:05 UTC
Ouch, bugzilla ate the rest of my comment after the trace... Let me post it again.

However, how is quite clear the issue is because the compositor's top_window_actor doesn't get nullified when that is destroyed. 
I've tried to track down when such destruction happens but it seems to be driven mostly by the JS engine and its garbage collector...
So not too easy to find where this unallocation happens (gjs_dumpstack does say nothing of course). See the trace:


  • #0 meta_window_actor_finalize
    at /media/M2/GNOME/mutter/src/compositor/meta-window-actor.c line 508
  • #1 g_object_unref
    at /media/M2/GNOME/glib/gobject/gobject.c line 3330
  • #2 release_native_object
    at /media/M2/GNOME/gjs/gi/object.cpp line 1133
  • #3 object_instance_finalize
    at /media/M2/GNOME/gjs/gi/object.cpp line 1525
  • #4 js::Class::doFinalize
    at /media/M2/GNOME/_BUILD/mozjs-52.2.1gnome1/dist/include/js/Class.h line 816
  • #5 JSObject::finalize
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsobjinlines.h line 87
  • #6 js::gc::Arena::finalize<JSObject>
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 457
  • #7 FinalizeTypedArenas<JSObject>
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 515
  • #8 FinalizeArenas
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 549
  • #9 js::gc::ArenaLists::forceFinalizeNow
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 2732
  • #10 js::gc::ArenaLists::finalizeNow
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 2714
  • #11 js::gc::ArenaLists::queueForegroundObjectsForSweep
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 2850
  • #12 js::gc::GCRuntime::beginSweepingZoneGroup
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 5144
  • #13 js::gc::GCRuntime::beginSweepPhase
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 5232
  • #14 js::gc::GCRuntime::incrementalCollectSlice
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 5913
  • #15 js::gc::GCRuntime::gcCycle
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 6201
  • #16 js::gc::GCRuntime::collect
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 6329
  • #17 js::gc::GCRuntime::gc
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 6397
  • #18 JS_GC
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsapi.cpp line 1326
  • #19 gjs_gc_if_needed
    at /media/M2/GNOME/gjs/gjs/jsapi-util.cpp line 746
  • #20 trigger_gc_if_needed
    at /media/M2/GNOME/gjs/gjs/context.cpp line 425
  • #21 g_main_dispatch
    at /media/M2/GNOME/glib/glib/gmain.c line 3182
  • #22 g_main_context_dispatch
    at /media/M2/GNOME/glib/glib/gmain.c line 3847
  • #23 g_main_context_iterate
    at /media/M2/GNOME/glib/glib/gmain.c line 3920
  • #24 g_main_loop_run
    at /media/M2/GNOME/glib/glib/gmain.c line 4116
  • #25 meta_run
    at /media/M2/GNOME/mutter/src/core/main.c line 648
  • #26 main
    at ../../gnome-shell/src/main.c line 530
  • #0 meta_window_actor_finalize
    at /media/M2/GNOME/mutter/src/compositor/meta-window-actor.c line 508
  • #1 g_object_unref
    at /media/M2/GNOME/glib/gobject/gobject.c line 3330
  • #2 release_native_object
    at /media/M2/GNOME/gjs/gi/object.cpp line 1133
  • #3 object_instance_finalize
    at /media/M2/GNOME/gjs/gi/object.cpp line 1525
  • #4 js::Class::doFinalize
    at /media/M2/GNOME/_BUILD/mozjs-52.2.1gnome1/dist/include/js/Class.h line 816
  • #5 JSObject::finalize
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsobjinlines.h line 87
  • #6 js::gc::Arena::finalize<JSObject>
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 457
  • #7 FinalizeTypedArenas<JSObject>
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 515
  • #8 FinalizeArenas
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 549
  • #9 js::gc::ArenaLists::forceFinalizeNow
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 2732
  • #10 js::gc::ArenaLists::finalizeNow
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 2714
  • #11 js::gc::ArenaLists::queueForegroundObjectsForSweep
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 2850
  • #12 js::gc::GCRuntime::beginSweepingZoneGroup
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 5144
  • #13 js::gc::GCRuntime::beginSweepPhase
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 5232
  • #14 js::gc::GCRuntime::incrementalCollectSlice
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 5913
  • #15 js::gc::GCRuntime::gcCycle
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 6201
  • #16 js::gc::GCRuntime::collect
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 6329
  • #17 js::gc::GCRuntime::gc
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsgc.cpp line 6397
  • #18 JS_GC
    at /media/M2/GNOME/mozjs-52.2.1gnome1/js/src/jsapi.cpp line 1326
  • #19 gjs_gc_if_needed
    at /media/M2/GNOME/gjs/gjs/jsapi-util.cpp line 746
  • #20 trigger_gc_if_needed
    at /media/M2/GNOME/gjs/gjs/context.cpp line 425
  • #21 g_main_dispatch
    at /media/M2/GNOME/glib/glib/gmain.c line 3182
  • #22 g_main_context_dispatch
    at /media/M2/GNOME/glib/glib/gmain.c line 3847
  • #23 g_main_context_iterate
    at /media/M2/GNOME/glib/glib/gmain.c line 3920
  • #24 g_main_loop_run
    at /media/M2/GNOME/glib/glib/gmain.c line 4116
  • #25 meta_run
    at /media/M2/GNOME/mutter/src/core/main.c line 648
  • #26 main
    at ../../gnome-shell/src/main.c line 530

Comment 2 Marco Trevisan (Treviño) 2017-11-29 23:08:04 UTC
Created attachment 364642 [details] [review]
compositor: add a weak-ref to nullify top_window_actor when it's removed

Adding a patch to fix this using a weak ref, as said I've not been able
to track this way further down, but I think this is still right to do.
Comment 3 Marco Trevisan (Treviño) 2017-11-30 19:09:42 UTC
Created attachment 364697 [details] [review]
compositor: also remove actors from the windows list

So, after digging a little bit into this, I found the real cause for this to happen, check this log:

Nov 30 13:40:58 ubuntu org.gnome.Shell.desktop[42385]: meta_compositor_sync_stack, top actor set to 0x5623cb0c27f0, meta window is 0x5623cbc94040
Nov 30 13:40:58 ubuntu org.gnome.Shell.desktop[42385]: meta_compositor_sync_stack, top actor set to 0x5623cb0c2bd0, meta window is 0x5623cbc94360
Nov 30 13:41:04 ubuntu org.gnome.Shell.desktop[42385]: meta_compositor_remove_window, Removing window 0x5623cbc94360, actor 0x5623cb0c2bd0 [top is 0x5623cb0c2bd0]
Nov 30 13:41:04 ubuntu org.gnome.Shell.desktop[42385]: meta_compositor_remove_window, Top actor was 0x5623cb0c2bd0 and got nullified
Nov 30 13:41:04 ubuntu org.gnome.Shell.desktop[42385]: meta_compositor_sync_stack, top actor set to 0x5623cb0c2bd0, meta window is 0x5623cbc94360
Nov 30 13:41:04 ubuntu gnome-shell[42385]: Object Meta.WindowActor (0x5623cb0c2bd0), has been already finalized. Impossible to get any property from it.                                                       
Nov 30 13:41:04 ubuntu gnome-shell[42385]: Object Meta.WindowActor (0x5623cb0c2bd0), has been already finalized. Impossible to set any property to it.

As you can see the top actor is set to 0x5623cb0c2bd0, then this is removed and requested to be destroyed, but at next sync_stack cycle, it's set back again as top_actor. This happens because the actor isn't removed from the compositor->windows list, and thus picked from the old_stack.
Updated the patch to also ensure we clear this actor from the said list, and the crash is fixed.
Comment 4 Marco Trevisan (Treviño) 2017-12-01 03:14:11 UTC
Created attachment 364711 [details] [review]
compositor: reset top_window_actor and remove it from windows when destroyed

As per discussion con Jonas, we decided it's better to remove the top
actor references when it gets really destroyed, as animations might
be still happening on the window actor.
Comment 5 Marco Trevisan (Treviño) 2017-12-01 03:17:22 UTC
Created attachment 364712 [details] [review]
window-actor: rename destroy function in maybe_destroy

Since this might delay the destruction after animation
has succeeded, it's just better to rename this accordingly.
Comment 6 Marco Trevisan (Treviño) 2017-12-01 03:19:06 UTC
(In reply to Marco Trevisan (Treviño) from comment #4)
> Created attachment 364711 [details] [review] [review]
> compositor: reset top_window_actor and remove it from windows when destroyed
> 
> As per discussion *con* Jonas

Sorry, I'm speaking spanish way too much these days :-D

s/con/with/
Comment 7 Jonas Ådahl 2017-12-01 03:40:25 UTC
Review of attachment 364711 [details] [review]:

just a naming nit. with that fixed, lgtm

::: src/compositor/compositor.c
@@ +954,3 @@
 
+static void
+on_top_stack_actor_destroyed (MetaWindowActor *window_actor,

nit: s/top_stack_actor/top_window_actor/
Comment 8 Jonas Ådahl 2017-12-01 03:42:22 UTC
Review of attachment 364712 [details] [review]:

Hmm. So "maybe_destroy" to me reads as it should be called multiple times until the maybe became definite. It's more of a "destroy now or later", but right now I can't think of a better name than just "destroy".. (unless its really _destroy_now_or_later() :P)
Comment 9 Marco Trevisan (Treviño) 2017-12-01 03:55:01 UTC
Patches pushed as commit b1587f0 and commit 1a1db9e