Skip to content

fix(wl_placement): read the geometry payload by structure, in any key order (runtime#1928) - #76

Merged
dfattal merged 1 commit into
mainfrom
fix/wl-placement-key-order
Oct 12, 2026
Merged

dfattal merged 1 commit into
mainfrom
fix/wl-placement-key-order

Conversation

@dfattal

@dfattal dfattal commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Reported by the KWin publisher author on DisplayXR/displayxr-runtime#1928.

Bug. DxrWlPlacement::get_own_geometry found keys by substring search from the first "pid":N,, assuming the GNOME extension's key order. With sorted keys (monitor before pid) and the caller's window last, mon was null and the unconditional device_scale lookup called strstr(nullptr): a segfault (reproduced against origin/main's helpers). In any other non-GNOME order it silently returned false. We never saw it because the GNOME extension always writes pid first and monitor after.

Fix. The parser moves into a pure header, common/linux/dxr_wl_geom_json.h. It walks the structure (top-level object → windows[] → window object → monitor object) and reads each key at its own depth, so key order, whitespace, pid prefixes (12 vs 123), key names inside strings and nested objects can't be misread. Rect integers still truncate, matching the runtime's cJSON consumer (comp_vk_native_wl_geom.c), so app and runtime agree on every pixel. No new dependency.

Test. New displayxr_linux_window_geom_json_test (GNOME order, fully sorted KWin order, decoys, failure cases), added to the linux_window CI job. The existing lattice/drag/input/scale tests pass locally.

🤖 Generated with Claude Code

… order (runtime#1928)

get_own_geometry searched substrings from the first `"pid":N,`, which
assumed the GNOME extension's key order (pid first, monitor after). A
publisher that writes keys sorted — the KWin publisher of runtime#1928 —
put "monitor" before "pid", so for the caller's last window `mon` was
null and the unconditional device_scale lookup called strstr(nullptr):
a segfault. In every other order it silently failed.

The parser moves into a pure header (dxr_wl_geom_json.h) that walks the
top-level object, the windows array, each window object and its monitor
object, and looks every key up at its own depth. A pid that prefixes
another, key names inside strings and nested objects can no longer be
misread. Rect integers still truncate, as the runtime's cJSON consumer
reads them.

New test displayxr_linux_window_geom_json_test (GNOME order, sorted
order, decoys, failures), run in CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant