Igalia / wolvic

A fast and secure browser for standalone virtual-reality and augmented-reality headsets.

Home Page:https://wolvic.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Memory corruption in xrCreateSession when EXTX_overlay is supported by runtime

rcelyte opened this issue · comments

Configuration

Wolvic version: any since 4a2fac1

Hardware: any

Steps to Reproduce

  1. Use a runtime that supports XR_EXTX_overlay (i.e. Monado)
  2. Attempt to launch Wolvic
  3. Observe errors and immediate crash

Current Behavior

The extension struct for enabling XR_EXTX_overlay is out of scope when passed to xrCreateSession(), resulting in the memory getting clobbered:

if (OpenXRExtensions::IsExtensionSupported(XR_EXTX_OVERLAY_EXTENSION_NAME)) {
XrSessionCreateInfoOverlayEXTX overlayInfo {
.type = XR_TYPE_SESSION_CREATE_INFO_OVERLAY_EXTX,
.createFlags = 0,
.sessionLayersPlacement = 0
};
auto oldNext = createInfo.next;
createInfo.next = &overlayInfo;
overlayInfo.next = oldNext;
}
CHECK_XRCMD(xrCreateSession(m.instance, &createInfo, &m.session));

Expected Behavior

Not crashing on startup

Possible Solution

Hoist the declaration of overlayInfo outside of the if statement so it remains in scope

Error Logs and Stack Traces

I VRB     : BrowserWorld::InitializeGL
D OXR     : XR_ERROR_GRAPHICS_DEVICE_INVALID: xrCreateSession(createInfo->next) Argument chain does not contain any known graphics bindings
E libc++abi: terminating with uncaught exception of type std::logic_error: XrResult failure [XR_ERROR_GRAPHICS_DEVICE_INVALID]
E libc++abi:     Origin: xrCreateSession(m.instance, &createInfo, &m.session)

What a timing :) I precisely spotted that yesterday, it was fixed by #1399