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

HookableEvent: Use std::recursive_mutex instead of std::mutex #11720

Merged

Conversation

Pokechu22
Copy link
Contributor

This fixes a crash when recording fifologs, as the mutex is acquired when BPWritten calls AfterFrameEvent::Trigger, but then acquired again when FifoRecorder::EndFrame calls m_end_of_frame_event.reset(). std::mutex does not allow calling lock() if the thread already owns the mutex, while std::recursive_mutex does allow this.

This is a regression from #11522 (which introduced the HookableEvent system).

This fixes a crash when recording fifologs, as the mutex is acquired when BPWritten calls AfterFrameEvent::Trigger, but then acquired again when FifoRecorder::EndFrame calls m_end_of_frame_event.reset(). std::mutex does not allow calling lock() if the thread already owns the mutex, while std::recursive_mutex does allow this.

This is a regression from dolphin-emu#11522 (which introduced the HookableEvent system).
@Pokechu22 Pokechu22 requested a review from phire April 2, 2023 22:59
@mackal
Copy link
Contributor

mackal commented Apr 3, 2023

I was able to record a FifoLog after this change, unsure about rest of the usages, but I wasn't seeing anything obvious.

@AdmiralCurtiss
Copy link
Contributor

Personally I see no reason for this to not be a recursive mutex, unless this was intended as some protection so you can't register/unregister events during a callback? I'm guessing not though.

@AdmiralCurtiss
Copy link
Contributor

I'm just gonna merge this since it fixes a known crash...

@AdmiralCurtiss AdmiralCurtiss merged commit 948a548 into dolphin-emu:master Apr 10, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants