Tk Source Code

View Ticket
Login
Ticket UUID: b43668246aad18d93df3e1551cac7d38a9beb53c
Title: Wayland branch: tk systray create fails without a StatusNotifierWatcher, and use after free after destroying the icon
Type: Bug Version: wayland
Submitter: serhiy.storchaka Created on: 2026-10-15 11:42:43
Subsystem: 99. Other Assigned To: kevin_walzer
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2026-11-10 01:33:32
Resolution: Fixed Closed By: kevin_walzer
    Closed on: 2026-11-10 01:33:32
Description:

tk systray create fails with "failed to register StatusNotifierItem" when no StatusNotifierWatcher is running (no tray, or GNOME without the AppIndicator extension). On X11 the icon is created and docked when a tray appears. All systray.test tests and sysnotify-1 fail in such an environment.

Also:

  • Two tooltip refresh timers and the pending icon redraw are not cancelled when the icon is destroyed, so destroying it within 1.5 seconds after creation uses freed memory.
  • A bad -image gives image "_book" does not existinvalid image name (systray-14).

Proposed fix in branch wayland-systray-no-watcher: a failed initial registration is not an error (the item is registered when a watcher appears, as the code already does), the timers and the idle callback are cancelled on destroy, and the message of Tk_GetImage() is kept.

User Comments: kevin_walzer added on 2026-11-10 01:33:32:
I re-merged wayland-systray-session-bus after verifying the fix in the test suite. Merging wayland-systray-no-watcher was no-op so I am assuming that fix is already contained in wayland-systray-session-bus.

serhiy.storchaka added on 2026-11-09 13:47:17:

Proposed change in branch wayland-systray-session-bus [3f63c152ba]:

  • A new constraint sessionBus skips the 11 systray tests that create an icon on Wayland when there is no session D-Bus (neither DBUS_SESSION_BUS_ADDRESS nor $XDG_RUNTIME_DIR/bus), as in a headless run without a bus. There they fail with "failed to register StatusNotifierItem". The constraint is always true on other platforms.
  • systray-16 and sysnotify-1 never ran on any platform, because constraints in a list must all be true (aqua X11, aqua x11 wayland). Their constraints and the setup of sysnotify-1 are restored from main, plus sessionBus.


kevin_walzer added on 2026-10-17 01:02:10:
This seems a very useful fix. Merging.