[fix](memory) Fix bthread_setspecific log fatal on UBSAN build (#18274)

This commit is contained in:
Xinyi Zou
2023-03-31 19:46:53 +08:00
committed by GitHub
parent 236ee1411e
commit 5e7ea5e305

View File

@ -191,6 +191,11 @@ private:
TUniqueId _fragment_instance_id;
};
#if defined(UNDEFINED_BEHAVIOR_SANITIZER)
static ThreadContext* thread_context() {
return thread_context_ptr._ptr;
}
#else
// Cache the pointer of bthread local in pthead local,
// Avoid calling bthread_getspecific frequently to get bthread local, which has performance problems.
static void pthread_attach_bthread() {
@ -225,6 +230,7 @@ static ThreadContext* thread_context() {
return thread_context_ptr._ptr;
}
}
#endif
class ScopeMemCount {
public: