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
WiimoteReal: Fix crash on real Wii Remote disconnect on Windows. #9460
WiimoteReal: Fix crash on real Wii Remote disconnect on Windows. #9460
Conversation
…d by dangling pointer.
This comment has been minimized.
This comment has been minimized.
| g_wiimotes[index] = nullptr; | ||
| // The Wii Remote object must exist through the call to UpdateSource | ||
| // to prevent WiimoteDevice from having a dangling HIDWiimote pointer. | ||
| const auto temp_real_wiimote = std::move(g_wiimotes[index]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess alternatively we could have just swapped these calls?
WiimoteCommon::UpdateSource(index);
g_wiimotes[index] = nullptr;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Unfortunately UpdateSource gives WiimoteDevice a new pointer by grabbing it from g_wiimotes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't UpdateSource going to reach here:
dolphin/Source/Core/Core/HW/Wiimote.cpp
Line 75 in 0029ca8
| hid_source = WiimoteReal::g_wiimotes[index].get(); |
.get() the moved-from index?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. We want it to get a null pointer here, to disconnect it from the HID interface.
The problem was a dangling pointer a bit earlier in Activate / SetBasebandState / m_hid_source->EventUnlinked().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, the comment is a bit confusing to me for some reason. anyway lgtm
I can't say I've ever had the issue of it crashing in the situation described in that bug report, but it still hangs and crashes in MacOS 11.0 when closing down Dolphin. |
Code for attaching a real Wii remote's HID interface to our emulated Bluetooth device is a bit messy.
A dangling pointer in the disconnect routine was causing a crash on Windows.
Fixes:
https://bugs.dolphin-emu.org/issues/12329
https://bugs.dolphin-emu.org/issues/12343
https://bugs.dolphin-emu.org/issues/12351
Possibly fixes this issue on macOS?
https://bugs.dolphin-emu.org/issues/9520