You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2022/10/17 00:52:21 UTC

[doris] branch master updated: [fix](memory) Fix USE_JEMALLOC=true UBSAN compilation error #13398

This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 9454bcca12 [fix](memory) Fix USE_JEMALLOC=true UBSAN compilation error #13398
9454bcca12 is described below

commit 9454bcca12f870c02b028778a1d18a2e632ef260
Author: Xinyi Zou <zo...@gmail.com>
AuthorDate: Mon Oct 17 08:52:14 2022 +0800

    [fix](memory) Fix USE_JEMALLOC=true UBSAN compilation error #13398
---
 be/CMakeLists.txt        | 18 +++++++++---------
 be/src/common/daemon.cpp |  6 +++---
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt
index 0674bc7922..6767d09dde 100644
--- a/be/CMakeLists.txt
+++ b/be/CMakeLists.txt
@@ -756,22 +756,22 @@ set(DORIS_LINK_LIBS ${DORIS_LINK_LIBS}
     -lresolv
 )
 
+if (USE_JEMALLOC)
+    set(MALLOCLIB jemalloc)
+else ()
+    set(MALLOCLIB tcmalloc)
+endif()
+
 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
     set(ASAN_LIBS -static-libasan)
     set(LSAN_LIBS -static-liblsan)
-    set(UBSAN_LIBS -static-libubsan tcmalloc)
+    set(UBSAN_LIBS -static-libubsan ${MALLOCLIB})
     set(TSAN_LIBS -static-libtsan)
 else ()
-    set(UBSAN_LIBS -rtlib=compiler-rt tcmalloc)
+    set(UBSAN_LIBS -rtlib=compiler-rt ${MALLOCLIB})
 endif ()
 
-if (USE_JEMALLOC)
-    set(MALLOCLIB jemalloc)
-else ()
-    set(MALLOCLIB tcmalloc)
-endif()
-
-# Add sanitize static link flags or tcmalloc
+# Add sanitize static link flags
 if ("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG" OR "${CMAKE_BUILD_TYPE}" STREQUAL "RELEASE")
     set(DORIS_LINK_LIBS ${DORIS_LINK_LIBS} ${MALLOCLIB})
 elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "ASAN")
diff --git a/be/src/common/daemon.cpp b/be/src/common/daemon.cpp
index 0492400e21..d3ac786c8b 100644
--- a/be/src/common/daemon.cpp
+++ b/be/src/common/daemon.cpp
@@ -69,6 +69,8 @@ bool k_doris_exit = false;
 
 void Daemon::tcmalloc_gc_thread() {
     // TODO All cache GC wish to be supported
+#if !defined(ADDRESS_SANITIZER) && !defined(LEAK_SANITIZER) && !defined(THREAD_SANITIZER) && \
+        !defined(USE_JEMALLOC)
     while (!_stop_background_threads_latch.wait_for(std::chrono::seconds(10))) {
         size_t used_size = 0;
         size_t free_size = 0;
@@ -87,6 +89,7 @@ void Daemon::tcmalloc_gc_thread() {
             }
         }
     }
+#endif
 }
 
 void Daemon::memory_maintenance_thread() {
@@ -264,13 +267,10 @@ void Daemon::init(int argc, char** argv, const std::vector<StorePath>& paths) {
 
 void Daemon::start() {
     Status st;
-#if !defined(ADDRESS_SANITIZER) && !defined(LEAK_SANITIZER) && !defined(THREAD_SANITIZER) && \
-        !defined(USE_JEMALLOC)
     st = Thread::create(
             "Daemon", "tcmalloc_gc_thread", [this]() { this->tcmalloc_gc_thread(); },
             &_tcmalloc_gc_thread);
     CHECK(st.ok()) << st.to_string();
-#endif
     st = Thread::create(
             "Daemon", "memory_maintenance_thread", [this]() { this->memory_maintenance_thread(); },
             &_memory_maintenance_thread);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org