Skip to content

Commit

Permalink
oboe: remove call to dlclose()
Browse files Browse the repository at this point in the history
Do not call dlclose on AAudio.
It could cause a segfault if thread_local was used by AAudio.
And the destructor is never called anyway so there is no resource leak.

Fixes #1160
  • Loading branch information
philburk committed Jan 14, 2021
1 parent 8e708ce commit 2ca99f6
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/aaudio/AAudioLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@
namespace oboe {

AAudioLoader::~AAudioLoader() {
if (mLibHandle != nullptr) {
dlclose(mLibHandle);
mLibHandle = nullptr;
}
// Issue 360: thread_local variables with non-trivial destructors
// will cause segfaults if the containing library is dlclose()ed on
// devices running M or newer, or devices before M when using a static STL.
// The simple workaround is to not call dlclose.
// /~https://github.com/android/ndk/wiki/Changelog-r22#known-issues
//
// The libaaudio and libaaudioclient do not use thread_local.
// But, to be safe, we should avoid dlclose() if possible.
// Because AAudioLoader is a static Singleton, we can safely skip
// calling dlclose() without causing a resource leak.
LOGI("%s() dlclose(%s) not called, OK", __func__, LIB_AAUDIO_NAME);
}

AAudioLoader* AAudioLoader::getInstance() {
Expand Down

0 comments on commit 2ca99f6

Please sign in to comment.