Skip to content

android: avoid OpenSL mixer lock recursion - #301

Closed
kumagi wants to merge 1 commit into
ebitengine:mainfrom
kumagi:audit/android-opensl-close-lock
Closed

kumagi wants to merge 1 commit into
ebitengine:mainfrom
kumagi:audit/android-opensl-close-lock

Conversation

@kumagi

@kumagi kumagi commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

What issue is this addressing?

No issue filed yet. Found during an audit of the vendored Oboe sources (Oboe 1.11.0).

What type of issue is this addressing?

bug

What this PR does | solves

In OutputMixerOpenSL::open (internal/oboe/oboe_opensles_OutputMixerOpenSLES_android.cpp), the error path calls close() while mLock is still held by open() itself:

SLresult OutputMixerOpenSL::open() {
    std::lock_guard<std::mutex> lock(mLock);   // mLock held for the whole call
    ...
    goto error;

error:
    close();        // close() takes mLock again
    return result;
}

void OutputMixerOpenSL::close() {
    std::lock_guard<std::mutex> lock(mLock);   // non-recursive -> deadlock
    ...
}

std::mutex is not recursive, so any failure of createOutputMix or Realize deadlocks the calling thread inside open().

The fix

Split the body of close() into closeLocked(), which assumes mLock is already held:

  • open()'s error path calls closeLocked() directly.
  • close() keeps the same contract and just wraps closeLocked() with the lock.

This mirrors the *Locked naming already used elsewhere in the binding (binding_android.cpp has StartLocked, StopLocked, etc.).

Note: this file is vendored from Oboe 1.11.0 by internal/oboe/gen.go; the same fix would ideally be applied upstream in google/oboe as well.

@hajimehoshi

Copy link
Copy Markdown
Member

We cannot fix Oboe source code directly. If you need, report the issue to github.com/google/oboe

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