t/north_star: Add slam device after HMD device.

The HMD display device apparently needs to be the first one in
the xdevs list. Comments in xrt_prober.h seem to confirm this.

Order hmd and slam device acccordingly in the north_star target
builder.

Otherwise XR client calls to xrEndFrame(), at least with projection
layers, will cause monado-service to crash, as it chooses the
"slam device" xdev as "HMD", instead of the actual hmd device,
and therefore dereferences a xdev->hmd which is NULL inside
_update_projection_layer() and thereby segfaults.

gdb backtrace after SIGSEGV:

_update_projection_layer (xc=0x7ffe60000bf0, ics=0x5555560a5208, layer=0x7fff0a5ed620, i=0) at /home/dragon/projects/monado/src/xrt/ipc/server/ipc_server_handler.c:749
749		uint32_t view_count = xdev->hmd->view_count;
(gdb) bt
0  _update_projection_layer (xc=0x7ffe60000bf0, ics=0x5555560a5208, layer=0x7fff0a5ed620, i=0) at /home/dragon/projects/monado/src/xrt/ipc/server/ipc_server_handler.c:749
1  0x00005555555abd30 in _update_layers (ics=0x5555560a5208, xc=0x7ffe60000bf0, slot=0x7fff0a5ed600) at /home/dragon/projects/monado/src/xrt/ipc/server/ipc_server_handler.c:973
2  0x00005555555ac060 in ipc_handle_compositor_layer_sync (ics=0x5555560a5208, slot_id=0, out_free_slot_id=0x7fff0a5ef134, handles=0x7fff0a5ef170, handle_count=0)
   at /home/dragon/projects/monado/src/xrt/ipc/server/ipc_server_handler.c:1058
3  0x00005555555a7167 in ipc_dispatch (ics=0x5555560a5208, ipc_command=0x7fff0a5ef840) at /home/dragon/projects/monado/build/src/xrt/ipc/ipc_server_generated.c:518
4  0x00005555555a56cc in client_loop (ics=0x5555560a5208) at /home/dragon/projects/monado/src/xrt/ipc/server/ipc_server_per_client_thread.c:191
5  0x00005555555a593d in ipc_server_client_thread (_ics=0x5555560a5208) at /home/dragon/projects/monado/src/xrt/ipc/server/ipc_server_per_client_thread.c:332

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2228>
This commit is contained in:
Mario Kleiner 2024-05-31 03:02:10 +01:00 committed by Marge Bot
parent b681a01f7f
commit e7cbcefac6

View file

@ -543,7 +543,6 @@ ns_open_system_impl(struct xrt_builder *xb,
struct xrt_device *head_wrap = NULL;
if (slam_device != NULL) {
xsysd->xdevs[xsysd->xdev_count++] = slam_device;
head_wrap = multi_create_tracking_override(XRT_TRACKING_OVERRIDE_DIRECT, ns_hmd, slam_device,
XRT_INPUT_GENERIC_TRACKER_POSE, &head_offset);
} else {
@ -556,6 +555,10 @@ ns_open_system_impl(struct xrt_builder *xb,
struct xrt_device *left_ht = NULL, *right_ht = NULL;
xsysd->xdevs[xsysd->xdev_count++] = head_wrap;
// Add slam device after HMD:
if (slam_device != NULL)
xsysd->xdevs[xsysd->xdev_count++] = slam_device;
if (hand_device != NULL) {
// note: hand_parented_to_head_tracker is always false when slam_device is NULL
struct xrt_device *hand_wrap = multi_create_tracking_override(