Skip to content

HideTracker: Guard against accessing invalid pointer#2860

Open
leolost2605 wants to merge 1 commit into
mainfrom
leolost/fix-wait-for-window-actor-crash
Open

HideTracker: Guard against accessing invalid pointer#2860
leolost2605 wants to merge 1 commit into
mainfrom
leolost/fix-wait-for-window-actor-crash

Conversation

@leolost2605

Copy link
Copy Markdown
Member

Fixes #2859

@garaevdi could you try if this fixes the crash for you?

Because I think your backtrace points more towards

if (!panel.window.is_ancestor_of_transient (new_window_actor.meta_window)) {

Also I think that not positionedwindow.window is null but rather the positionedwindow itself was already freed because the hidetracker only holds an unowned reference on it. The HideTracker however isn't freed because it is captured by the wait for window actor callback.

With this PR we guard against accessing that reference if the window was unmanaged.

For now I hope this should fix it but we had this problem in the past a few times so I think I'll follow up some time by just passing the meta.window and the anchor instead of the whole panelwindow to avoid having to hold an unowned reference.

@leolost2605 leolost2605 requested a review from a team June 27, 2026 12:16
@garaevdi

garaevdi commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Yes, that seems to fix it. Could you also add the same safeguard before this line

var has_pointer = panel.window.has_pointer ();

because even with this patch applied, sometimes I get this backtrace

Core was generated by `/usr/bin/gala'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000055e6f519bb41 in gala_positioned_window_get_window (self=0x55e7356c72f0) at ../src/ShellClients/PositionedWindow.vala:9
9	    public Meta.Window window { get; construct; }
[Current thread is 1 (Thread 0x7feff60c1fc0 (LWP 3699))]
(gdb) bt
#0  0x000055e6f519bb41 in gala_positioned_window_get_window (self=Invalid quark 4213827520
0x55e7356c72f0) at ../src/ShellClients/PositionedWindow.vala:9
#1  _gala_hide_tracker___lambda41_ (self=0x55e73620ead0 [GalaHideTracker]) at ../src/ShellClients/HideTracker.vala:60
#2  __gala_hide_tracker___lambda41__meta_cursor_tracker_position_invalidated
    (_sender=0x55e7354d60a0 [MetaCursorTracker], self=0x55e73620ead0) at ../src/ShellClients/HideTracker.vala:59
#7  0x00007feffb1d8d33 in <emit signal 'position-invalidated' on instance 0x55e7354d60a0 [MetaCursorTracker]>
    (instance=instance@entry=0x55e7354d60a0, signal_id=<optimized out>, detail=detail@entry=0) at ../gobject/gsignal.c:3624
    #3  0x00007feffb1b7e7c in g_closure_invoke
    (closure=0x55e7362ac970, return_value=0x0, n_param_values=1, param_values=0x7ffdae6184c0, invocation_hint=0x7ffdae618410)
    at ../gobject/gclosure.c:916
    #4  0x00007feffb1d6809 in signal_emit_unlocked_R
    (node=node@entry=0x7ffdae6185e0, detail=detail@entry=0, instance=instance@entry=0x55e7354d60a0, emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7ffdae6184c0) at ../gobject/gsignal.c:3929
    #5  0x00007feffb1d89e8 in signal_emit_valist_unlocked
    (instance=instance@entry=0x55e7354d60a0, signal_id=signal_id@entry=206, detail=detail@entry=0, var_args=var_args@entry=0x7ffdae618740)
    at ../gobject/gsignal.c:3561
    #6  0x00007feffb1d8c78 in g_signal_emit_valist
    (instance=0x55e7354d60a0, signal_id=206, detail=0, var_args=var_args@entry=0x7ffdae618740) at ../gobject/gsignal.c:3304
#8  0x00007feff9c4e76c in meta_cursor_tracker_invalidate_position (tracker=0x55e7354d60a0 [MetaCursorTracker])
    at ../src/backends/meta-cursor-tracker.c:403
#9  meta_backend_update_from_event (backend=0x55e733310810 [MetaBackendNative], event=0x7fef380edb70)
    at ../src/backends/meta-backend.c:2050
#10 meta_backend_update_from_event (backend=0x55e733310810 [MetaBackendNative], event=0x7fef380edb70)
    at ../src/backends/meta-backend.c:2027
#11 dispatch_clutter_event (backend=0x55e733310810 [MetaBackendNative]) at ../src/backends/meta-backend.c:1133
#12 0x00007feff9c4e8f1 in clutter_source_dispatch (source=0x55e73351e590, callback=<optimized out>, user_data=<optimized out>)
    at ../src/backends/meta-backend.c:1176
#13 0x00007feffb092f24 in g_main_dispatch (context=0x55e733306fc0) at ../glib/gmain.c:3591
#14 g_main_context_dispatch_unlocked (context=0x55e733306fc0) at ../glib/gmain.c:4451
#15 0x00007feffb097038 in g_main_context_iterate_unlocked
    (context=0x55e733306fc0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/gmain.c:4516
#16 0x00007feffb0972e7 in g_main_loop_run (loop=0x55e7356c6d60) at ../glib/gmain.c:4721
#17 0x00007feff9cb546a in meta_context_run_main_loop (context=<optimized out>, error=error@entry=0x7ffdae618a48)
    at ../src/core/meta-context.c:506
#18 0x000055e6f516729f in gala_main (args=<optimized out>, args_length1=<optimized out>) at ../src/Main.vala:92
#19 0x00007feff94f5681 in __libc_start_call_main (main=main@entry=0x55e6f5151660 <main>, argc=argc@entry=1, argv=argv@entry=0x7ffdae618df8)
    at ../sysdeps/nptl/libc_start_call_main.h:59
#20 0x00007feff94f5798 in __libc_start_main_impl
    (main=0x55e6f5151660 <main>, argc=1, argv=0x7ffdae618df8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_e
nd=0x7ffdae618de8) at ../csu/libc-start.c:360
#21 0x000055e6f51516a5 in _start ()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PositionedWindow.window can be null

2 participants