-
-
Notifications
You must be signed in to change notification settings - Fork 2
fix(audio): stop the audio pump re-taking the lock its caller already holds #12
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2461e01
fix(audio): stop the pump re-taking the lock its caller already holds
datagutt dbd9a99
fix(threading): handle mutex init failure instead of ignoring it
datagutt f797d36
feat(threading): catch nested lock acquires instead of hanging on them
datagutt ba6a726
feat(threading): catch unlocking an unheld lock on Windows too
datagutt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
Repository: irlserver/obs-irl-source
Length of output: 9488
🏁 Script executed:
Repository: irlserver/obs-irl-source
Length of output: 46956
🌐 Web query:
Microsoft documentation LeaveCriticalSection caller must own critical section undefined behavior OwningThread CRITICAL_SECTION💡 Result:
According to official Microsoft documentation, the LeaveCriticalSection function requires that the calling thread must be the same thread that acquired ownership of the critical section [1][2][3]. If a thread calls LeaveCriticalSection without owning the specified critical section object, the behavior is undefined [4]. Specifically, Microsoft explicitly states that this error can cause other threads using EnterCriticalSection to wait indefinitely [1][3][5]. Regarding the CRITICAL_SECTION structure, the OwningThread member is an internal implementation detail and is not intended for public use [6][7]. While historically documented or exposed in some headers as a HANDLE (and effectively holding the thread ID of the current owner), relying on this member is strongly discouraged [6][7]. Modifying or reading this member outside of the synchronization API functions is unsupported, and the internal implementation of critical sections can and does change across Windows versions (e.g., the transition to WaitOnAddress in Windows 10) [4][6][8]. In summary: 1. Attempting to release a critical section from a thread that does not own it is a violation of the API contract, resulting in undefined behavior and potential permanent deadlocks for other threads [1][4]. 2. The OwningThread member is an internal detail. Developers should not access or rely on it, as doing so leads to brittle code that is susceptible to breaking due to OS-level changes [6][7].
Citations:
Add ownership checks to Windows checked locks.
When
IRL_CHECKED_LOCKSis enabled,irl_mutex_unlock_checkeddiscardsfileandlineand callsLeaveCriticalSectionwithout checking ownership. An invalidLeaveCriticalSectioncall has undefined behavior and can deadlock other threads. Add wrapper-owned ownership tracking and callirl_lock_abortbefore unlocking. Keep the tracking correct acrossSleepConditionVariableCS.🤖 Prompt for AI Agents