Window constructor crashes on compositors without fractional-scale, xdg-decoration or viewporter (null globals) #162

Open
opened 2026-10-06 13:25:46 +00:00 by jorijnvdgraaf · 0 comments

Summary

The Window constructor uses three optional Wayland globals without checking that the compositor advertised them. On a compositor that lacks any one of them the constructor passes a null proxy to libwayland and crashes. Line numbers refer to 6aa0338.

Details

Device::handle_global binds these when they are advertised (implementations/Crafter.Graphics-Device.cpp:277-282), and Device::Initialize only verifies wl_shm, wl_compositor and xdg_wm_base (:527):

Global Used unconditionally at
wp_fractional_scale_manager_v1 implementations/Crafter.Graphics-Window.cpp:295
zxdg_decoration_manager_v1 :302
wp_viewporter :305

The rest of the code half-anticipates this: Resize already guards if (wpViewport) (:544).

Found by reading the code. Not reproduced: the compositors at hand (phoc on the Fairphone 6, and the desktop session) advertise all three. The likely first victim is a compositor without xdg-decoration; to my knowledge GNOME's Mutter does not implement it.

Suggested fix

Guard each use and degrade:

  • no fractional-scale manager → integer scale from wl_output / wl_surface.preferred_buffer_scale, or 1.0;
  • no decoration manager → skip the decoration request (the window is then undecorated or client-decorated);
  • no viewporter → skip the viewport, which also means no fractional scaling.
## Summary The `Window` constructor uses three optional Wayland globals without checking that the compositor advertised them. On a compositor that lacks any one of them the constructor passes a null proxy to libwayland and crashes. Line numbers refer to `6aa0338`. ## Details `Device::handle_global` binds these when they are advertised (`implementations/Crafter.Graphics-Device.cpp:277-282`), and `Device::Initialize` only verifies `wl_shm`, `wl_compositor` and `xdg_wm_base` (`:527`): | Global | Used unconditionally at | |---|---| | `wp_fractional_scale_manager_v1` | `implementations/Crafter.Graphics-Window.cpp:295` | | `zxdg_decoration_manager_v1` | `:302` | | `wp_viewporter` | `:305` | The rest of the code half-anticipates this: `Resize` already guards `if (wpViewport)` (`:544`). Found by reading the code. Not reproduced: the compositors at hand (phoc on the Fairphone 6, and the desktop session) advertise all three. The likely first victim is a compositor without xdg-decoration; to my knowledge GNOME's Mutter does not implement it. ## Suggested fix Guard each use and degrade: - no fractional-scale manager → integer scale from `wl_output` / `wl_surface.preferred_buffer_scale`, or 1.0; - no decoration manager → skip the decoration request (the window is then undecorated or client-decorated); - no viewporter → skip the viewport, which also means no fractional scaling.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Catcrafts/Crafter.Graphics#162
No description provided.