-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
c++11 thread_local objects don't get their destructors called on devices lower than android M #687
Comments
It looks like the libcxxabi
If the fallback destructor is called after the emutls destructor, then it will use deallocated storage. The workaround for the internal issue (delay the emutls deallocation a few rounds) probably fixes this issue, too. Android M adds |
Is this something a new ndk can fix, or are we totally hooped on older api's? |
(the details of the problems with the various thread local choices seem like they should be added to the docs, given the number of folks hitting these now...) |
Currently, I think this bug can be fixed in libgcc (and/or compiler-rt, if we upgrade to it), which is packaged with the NDK and linked into app shared libs. You'd need a new NDK, and then apps would work correctly on pre-M platforms. |
that's good news, thanks |
gnustl (which is deprecated) can fail on any Android version because, unlike libc++, its Like Android gnustl, mingw-w64 uses both emutls and libsupc++'s Edit: s/__cxa_thread_atexit/__cxa_thread_atexit_impl/. |
The NDK's libgcc.a prebuilts were updated in https://android-review.googlesource.com/c/platform/prebuilts/ndk/+/708782. |
* Update ndk from branch 'master' to 3a21fd712122f16879ce937f0041c7b34a966c17 - Merge "Test emutls pthread key deletion" - Test emutls pthread key deletion The key should be deleted when an solib is dlclose'd, but __thread variables should continue working during cleanup functions. Bug: b/80453944 Test: manual Change-Id: Ie5719f6228911d4e9f8f58b86f994765a713691f * Update prebuilts/ndk from branch 'dev' to f0908f8e2856919868742937450d197b08d37073 - Merge "Update prebuilt GCC to build 4886780." into dev - Update prebuilt GCC to build 4886780. Test: ndk/checkbuild.py && ndk/run_tests.py Bug: android/ndk#505 Bug: http://b/80453944 Change-Id: I1bd7fe862704a10f24806de23bc67ec3f15e4cb4 - Merge "Update prebuilt GCC to build 4856068." into dev - Update prebuilt GCC to build 4856068. Update libgcc.a with a change to defer per-thread emutls cleanup by one round. Bug: android/ndk#687 Bug: b/78022094 Test: ./checkbuild.py && ./run_tests.py --filter=emutls-dealloc Change-Id: I413b4bd926472bb50865d4b91431302f803a49e6 - Merge "Update NDK platform prebuilts to build 4828202." into dev - Update NDK platform prebuilts to build 4828202. Test: ndk/checkbuild.py && ndk/run_tests.py Bug: None Change-Id: Ib963ec9d8afe1ff84dc9586eb774aad6c9d1236b - Merge "Update NDK platform prebuilts to build 4811751." into dev - Update NDK platform prebuilts to build 4811751. Test: ndk/checkbuild.py && ndk/run_tests.py Bug: None Change-Id: If2aaaf6fe05ea63c8e340908f8f00d218219ddfb - Merge "Update NDK platform prebuilts to build 4794421." into dev - Update NDK platform prebuilts to build 4794421. Test: ndk/checkbuild.py && ndk/run_tests.py Bug: android/ndk#702 Change-Id: I84362b1b3f1bec6236866cdae617a811abfd5f52 - Merge "Update prebuilt Clang to build r328903." into dev - Merge "Adapt to the new Clang naming scheme." into dev - Adapt to the new Clang naming scheme. Clang prebuilts are now named as clang-r${REVISION}${PATCH} rather than as clang-${BUILD_NUMBER}. Test: ./symlink-clang.py Bug: None Change-Id: I758feecb05ad568560333f63d3e0e9cdc25f9bcd - Update prebuilt Clang to build r328903. Change-Id: I07c5832446733f09aa48ff8a0c13d89516e69370 - Merge "Update NDK platform prebuilts to build 4753280." into dev - Update NDK platform prebuilts to build 4753280. Test: ndk/checkbuild.py && ndk/run_tests.py Bug: None Change-Id: Ic062d17cf3a7de3c82ea1d9a875c6cb3dc141b23 - Merge "Update prebuilt binutils to build 4724899." into dev - Merge "Don't fetch the repo.prop for platform prebuilts." into dev - Don't fetch the repo.prop for platform prebuilts. Not necessary. Test: ./update_platform.py ... Bug: None Change-Id: I079c65caedaf5c1a3f270af721133051aee00c0b - Update prebuilt binutils to build 4724899. Test: ndk/checkbuild.py && ndk/run_tests.py Bug: None Change-Id: I951f53a8bfc258eb4501df8d84e255bd1e1cc1f1 - Merge "Update prebuilt Clang to build 4691093." into dev - Update prebuilt Clang to build 4691093. Change-Id: Ibe8c95936a0bbb46a172f8efcd4a00386dfa5e8c - Merge "Update Validation layer binaries" into dev - Merge "Update prebuilt Clang to build 4639204." into dev - Update Validation layer binaries Build: 4634174 https://android-build.googleplex.com/builds/branch-dashboard/aosp-master-ndk-vulkan-validation-layers?build_id=4634174 Change-Id: I55d4ca67aa390d288c6c0f04bbafb21dee31aab8 - Merge "Update NDK platform prebuilts to build 4634113." into dev - Update prebuilt Clang to build 4639204. Change-Id: I456b400bc534de579078665a48ae5235869fb3f3 - Update NDK platform prebuilts to build 4634113. Test: ndk/checkbuild.py && ndk/run_tests.py Bug: None Change-Id: I9e7aa333073c61ba2724a6cd39f7b7e30ff2fef6 - Merge "Update prebuilt Clang to build 4630689." into dev - Merge "Update NDK platform prebuilts to build 4634436." into dev - Update NDK platform prebuilts to build 4634436. Test: ndk/checkbuild.py && ndk/run_tests.py Bug: None Change-Id: Idd13dfe5dc9b928b81b48a0e72dc8ae669739275 - Update prebuilt Clang to build 4630689. Change-Id: I852722d2bdfb4aeaa42fe943677d7adbf679d61b
With Android/Bionic, delay deallocation to round 2 of 4. It must run after C++ thread_local destructors have been called, but before the final 2 rounds, because emutls calls free, and jemalloc then needs another 2 rounds to free its thread-specific data. Bug: android/ndk#687 Bug: b/78022094 Test: manual Test: ./run_tests.py --rebuild --filter emutls-dealloc Change-Id: I01bd634d97b7d22161b5cc8ca71b3cb94064a03e
Description
c++11 thread_local objects don't get their destructors called on devices lower than android M.
put this code in a thread and destroy it.
on api 23 the destructor gets called, on api 22 it does not.
Environment Details
The text was updated successfully, but these errors were encountered: