[BUG]The destructor of the thread_local object is not called when the thread terminates.
- Dominant language
- No language data
- Stars
- 2.3k
- Forks
- 310
- PR merge metrics
- No merged PRs in 30d
Description
### Description
When I use a static thread_local object in thread, the object's destructor is not called after the thead exit. The sample code is as follow. Is ndk don't support TLS?
```c++
static void threadLocalTest() {
class Demo {
public:
Demo() {
ALOGD("Demo()");
}
~Demo() {
ALOGD("~Demo()");
}
};
auto func = []() {
static thread_local Demo demo;
};
std::thread t1(func);
std::thread t2(func);
t1.join();
t2.join();
}
```
Environment Details:
NDK Version: 29.0.14206865
Build sytem: cmake 3.31.6
Host OS: Windows
Compiler: Clang
ABI: arm64-v8a
STL: c++_shared
NDK API level:
Device API level: 36
### I am using a supported NDK
- [x] I have checked and the NDK I'm using is currently supported
### Affected versions
r29, r28
Contributor guide
Research direction
Start by reproducing the sample using static thread_local Demo objects in std::thread with the listed NDK, ABI, STL, and API levels. Compare destructor behavior when t1 and t2 join, then determine whether the issue is specific to the Android NDK runtime; done means confirming the cause and identifying the affected configuration or required fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100