Skip to content

thread-safety-analysis fails on AudioStreamOpenSLES.cpp #2312

@jim-signal

Description

@jim-signal

Oboe version: 1.9.2 (but still applies in 1.10.0)

Short description
When building oboe with the WebRTC toolchain (a recent version such as m140), it fails since thread safety checks are enabled now by default.

Steps to reproduce
Add the -Wthread-safety compiler option and build.

Expected behavior
No compiler errors (since WebRTC is set to error out for this with -Werror,-Wthread-safety-analysis).

Actual behavior

src/opensles/AudioStreamOpenSLES.cpp:400:15: error: releasing mutex 'mLock' that was not held [-Werror,-Wthread-safety-analysis]
  400 |         mLock.unlock();
      |               ^
src/opensles/AudioStreamOpenSLES.cpp:405:5: error: mutex 'mLock' is not held on every path through here [-Werror,-Wthread-safety-analysis]
  405 |     onAfterDestroy();
      |     ^
src/opensles/AudioStreamOpenSLES.cpp:402:15: note: mutex acquired here
  402 |         mLock.lock();
      |               ^

Any additional context
A workaround is to disable the check only for oboe with "-Wno-sign-compare", which is fine and the same as it was before. But it would be nice if the check worked. I am not sure if there is a specific annotation for this or just use NO_THREAD_SAFETY_ANALYSIS for the function.

Related to the fix provided here: #591

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions