thread-safety-analysis fails on AudioStreamOpenSLES.cpp
- Dominant language
- C++
- Stars
- 4.1k
- Forks
- 639
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 8
Description
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: https://github.com/google/oboe/issues/591
Contributor guide
Assessment
This issue has not been assessed yet.