From 5e7ea5e3051618b9ab1f14e41f54f0fc616a29dc Mon Sep 17 00:00:00 2001 From: Xinyi Zou Date: Fri, 31 Mar 2023 19:46:53 +0800 Subject: [PATCH] [fix](memory) Fix `bthread_setspecific` log fatal on UBSAN build (#18274) --- be/src/runtime/thread_context.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/be/src/runtime/thread_context.h b/be/src/runtime/thread_context.h index 0d0896cc10..e4a707d2be 100644 --- a/be/src/runtime/thread_context.h +++ b/be/src/runtime/thread_context.h @@ -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: