8000 Resource Manager: Unlock the data buffer tree on failed unregister. by niu2x · Pull Request #1197 · mackron/miniaudio · GitHub
[go: up one dir, main page]

Skip to content

Resource Manager: Unlock the data buffer tree on failed unregister. - #1197

Open
niu2x wants to merge 1 commit into
mackron:masterfrom
niu2x:bugfix/resource-manager-unregister-lock
Open

niu2x wants to merge 1 commit into
mackron:masterfrom
niu2x:bugfix/resource-manager-unregister-lock

Conversation

@niu2x
@niu2x niu2x commented Nov 11, 2026
Copy link
Copy Markdown

Fix resource manager deadlock when unregistering missing resources

Unregistering a missing or already-unregistered resource returns MA_DOES_NOT_EXIST while leaving dataBufferBSTLock locked. Subsequent resource operations then hang.

Move stage2 before the unlock so all error exits release the mutex.

Adds a device-independent regression test covering missing resources, repeated unregisters, shared references, and narrow/wide names.

Validation

  • Original code times out; fixed code passes 100 rounds.
  • ASan/UBSan, C89, and C++11 checks pass.

Unregistering a missing or already-unregistered resource jumps to stage2
while dataBufferBSTLock is still held. The call returns MA_DOES_NOT_EXIST,
but subsequent resource registrations and unregisters block indefinitely.

Move stage2 before the unlock so all exits from the critical section
release the mutex before checking the result.

Add a device-independent regression test using registered PCM data. It
covers missing resources, repeated unregisters, shared registrations,
and narrow/wide names for 100 rounds. Give the CTest a timeout so the
original deadlock fails rather than hanging the test run indefinitely.

Verified that the unpatched source times out. The patched test passes
with warnings as errors, ASan/UBSan, C89, and C++11 builds.

This branch has not been deployed

No deployments
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.

1 participant

0