Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(client_openxr): 🐛 Fix crash caused by undefined behavior #2391

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

zmerp
Copy link
Member

@zmerp zmerp commented Sep 13, 2024

This PR attempts to fix a crash reported when enabling face tracking on the Quest Pro.

This PR fixes undefined behavior using a specific solution. Before we were calling System<props>::out() which returns a MaybeUninit, and immediately call assume_uninit(). Doing so only the corresponding BaseOutStructure fields are initialized, that is ty and next. The other fields are filled with random values. Beside this, calling assume_uninit() after attempting to get the properties with get_system_properties is not enough. The OpenXR spec doesn't say to return an error if the next pointer is populated with an unknown structure. So after the get_system_properties call, the System<props> struct might still contain random values. Because of this we should ditch the out() method and manually initialize the structure. The upstream openxrs crate suffers from the same bug, but only concerning the hand tracking extension. That instance of the bug hasn't surfaced yet.

@zmerp zmerp merged commit 74924a2 into master Sep 13, 2024
9 checks passed
@Vixea Vixea deleted the fix-openxr-ext-ub branch September 13, 2024 01:52
@zmerp zmerp mentioned this pull request Sep 20, 2024
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.

2 participants