Skip to content

Conversation

@alvinhochun
Copy link
Contributor

There was a null pointer dereference bug in weak_ref::get(). This happens to not cause any issues with MSVC, but does crash with MinGW ABI when built with optimizations, because a cast in winrt::get_self would adjust the (null) pointer by an offset due to the different vtable layout, which ends up escaping null checks.

I didn't notice this earlier because all my tests happen to be unoptimized Debug builds. I tracked down this bug with the help of UBSan.

Because of this, I have also enabled Release build checks for llvm-mingw, and enabled ASan+UBSan for the tests in Debug builds.

This happens to not cause any issues with MSVC, but does crash with
MinGW ABI when built with optimizations, because a cast in
`winrt::get_self` would adjust the (null) pointer by an offset due to
the different vtable layout, which ends up escaping null checks.
@kennykerr kennykerr merged commit 37bd17f into microsoft:master Nov 21, 2022
@alvinhochun alvinhochun deleted the alvin/weakref-crash-fix branch December 11, 2022 16:48
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