-
-
Notifications
You must be signed in to change notification settings - Fork 21k
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
Crash on exit when using OpenXRExtensionWrapperExtension #88613
Milestone
Comments
I just posted PR #88688 which provides a way to fix I'm going to make an alternative PR that just fixes this for |
And here's PR #88689 which is just a targeted fix for this specific bug :-) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tested versions
System information
Windows 11, gl_compatibility, NVidia RTX 3070 TI
Issue description
When terminating a Godot application which uses any OpenXRExtensionWrapperExtension objects, the application terminates in a call of
memdelete(extension_wrapper)
with a pointer that isn't a valid block of heap memory.The problem is caused by the inheritance structure of OpenXRExtensionWrapperExtension:
godot/modules/openxr/extensions/openxr_extension_wrapper_extension.h
Line 42 in 652438a
The problem occurs when
OpenXRExtensionWrapperExtension::register_extension_wrapper()
registers this class withOpenXRAPI::register_extension_wrapper()
AS AN OpenXRExtensionWrapper:godot/modules/openxr/extensions/openxr_extension_wrapper_extension.cpp
Lines 233 to 235 in 652438a
The OpenXRAPI extension wrappers saves OpenXRExtensionWrapper instances in a
Vector<OpenXRExtensionWrapper *>
and later deletes them usingmemdelete
.The problem is that the memory layout of OpenXRExtensionWrapperExtension is as follows (sizes specific to Windows/X64):
When the
OpenXRExtensionWrapperExtension::register_extension_wrapper()
registers itself, it has to cast itsthis
pointer to anOpenXRExtensionWrapper*
which involves adding 408 to the pointer value to jump over theObject
. Whenmemdelete()
is called on this pointer, it fails because the pointer isn't a block of allocated memory.This pattern is fully supported in C++ using the normal new/delete, as the compiler will generate a "virtual deleting destructor" in the objects VTABLE, so a delete by any class type will correctly call the real destructor, then adjust the pointer to the start of the object and delete the memory.
Godot's use of memdelete() appears to bypass this machinery preventing safe deletion of multiple-inheritance classes.
Steps to reproduce
Run Godot with the godot_openxr_vendors extension (or any extension providing OpenXR extensions) and then terminate the application.
Minimal reproduction project (MRP)
N/A
The text was updated successfully, but these errors were encountered: