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?
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
Affected versions
r29, r28