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

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

commit 8218bfd9ac39ebe5c74a8fb14fed9b3515011971
Author: Xinyi Zou <zouxi...@selectdb.com>
AuthorDate: Fri Dec 13 11:33:36 2024 +0800

    [fix](memory) Disable Jemalloc Hook and loading libjvm at runtime  (#45210)
    
    fix:
    ```
    *** Aborted at 1733734087 (unix time) try "date -d @1733734087" if you are 
using GNU date ***
    *** Current BE git commitID: 43f06a5e26 ***
    *** SIGSEGV address not mapped to object (@0x0) received by PID 1671420 
(TID 1671420 OR 0x7f4f35f74ac0) from PID 0; stack trace: ***
     0# doris::signal::(anonymous namespace)::FailureSignalHandler(int, 
siginfo_t*, void*) at 
/home/zcp/repo_center/doris_release/doris/be/src/common/signal_handler.h:421
     1# PosixSignals::chained_handler(int, siginfo*, void*) [clone .part.0] in 
/usr/local/jdk-17.0.2/lib/server/libjvm.so
     2# JVM_handle_linux_signal in /usr/local/jdk-17.0.2/lib/server/libjvm.so
     3# 0x00007F4F34340400 in /lib64/libc.so.6
     4# je_arena_dalloc_promoted at ../src/arena.c:1277
     5# je_free_default at ../src/jemalloc.c:3014
     6# __pthread_create_2_1 in /lib64/libpthread.so.0
     7# os::create_thread(Thread*, os::ThreadType, unsigned long) in 
/usr/local/jdk-17.0.2/lib/server/libjvm.so
     8# JVM_StartThread in /usr/local/jdk-17.0.2/lib/server/libjvm.so
     9# 0x00007F4F0A96C918
    ```
---
 be/src/http/default_path_handlers.cpp   |  2 +-
 be/src/runtime/CMakeLists.txt           |  4 +---
 be/src/runtime/memory/heap_profiler.cpp |  8 ++++----
 be/src/util/mem_info.cpp                |  2 +-
 be/src/util/mem_info.h                  | 10 +++++-----
 be/src/vec/common/allocator.h           |  2 +-
 thirdparty/build-thirdparty.sh          |  4 +++-
 7 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/be/src/http/default_path_handlers.cpp 
b/be/src/http/default_path_handlers.cpp
index 30c35426f85..3ddc02b2c77 100644
--- a/be/src/http/default_path_handlers.cpp
+++ b/be/src/http/default_path_handlers.cpp
@@ -113,7 +113,7 @@ void mem_usage_handler(const WebPageHandler::ArgumentMap& 
args, std::stringstrea
         auto* _opaque = static_cast<std::string*>(opaque);
         _opaque->append(buf);
     };
-    jemalloc_stats_print(write_cb, &tmp, "a");
+    malloc_stats_print(write_cb, &tmp, "a");
     boost::replace_all(tmp, "\n", "<br>");
     (*output) << tmp << "</pre>";
 #else
diff --git a/be/src/runtime/CMakeLists.txt b/be/src/runtime/CMakeLists.txt
index a0b3b799a76..ab380f9711f 100644
--- a/be/src/runtime/CMakeLists.txt
+++ b/be/src/runtime/CMakeLists.txt
@@ -25,9 +25,7 @@ set(EXECUTABLE_OUTPUT_PATH "${BUILD_DIR}/src/runtime")
 
 file(GLOB_RECURSE RUNTIME_FILES CONFIGURE_DEPENDS *.cpp *.cc)
 
-if (NOT USE_JEMALLOC OR NOT USE_MEM_TRACKER)
-    list(REMOVE_ITEM RUNTIME_FILES 
${CMAKE_CURRENT_SOURCE_DIR}/memory/jemalloc_hook.cpp)
-endif()
+list(REMOVE_ITEM RUNTIME_FILES 
${CMAKE_CURRENT_SOURCE_DIR}/memory/jemalloc_hook.cpp)
 
 add_library(Runtime STATIC
     ${RUNTIME_FILES}
diff --git a/be/src/runtime/memory/heap_profiler.cpp 
b/be/src/runtime/memory/heap_profiler.cpp
index 01ed82f76ef..0b0448ce0ea 100644
--- a/be/src/runtime/memory/heap_profiler.cpp
+++ b/be/src/runtime/memory/heap_profiler.cpp
@@ -30,8 +30,8 @@ void HeapProfiler::set_prof_active(bool prof) {
 #ifdef USE_JEMALLOC
     std::lock_guard guard(_mutex);
     try {
-        int err = jemallctl("prof.active", nullptr, nullptr, &prof, 1);
-        err |= jemallctl("prof.thread_active_init", nullptr, nullptr, &prof, 
1);
+        int err = mallctl("prof.active", nullptr, nullptr, &prof, 1);
+        err |= mallctl("prof.thread_active_init", nullptr, nullptr, &prof, 1);
         if (err) {
             LOG(WARNING) << "jemalloc heap profiling start failed, " << err;
         } else {
@@ -48,7 +48,7 @@ bool HeapProfiler::get_prof_dump(const std::string& 
profile_file_name) {
     std::lock_guard guard(_mutex);
     const char* file_name_ptr = profile_file_name.c_str();
     try {
-        int err = jemallctl("prof.dump", nullptr, nullptr, &file_name_ptr, 
sizeof(const char*));
+        int err = mallctl("prof.dump", nullptr, nullptr, &file_name_ptr, 
sizeof(const char*));
         if (err) {
             LOG(WARNING) << "dump heap profile failed, " << err;
             return false;
@@ -93,7 +93,7 @@ bool HeapProfiler::check_heap_profiler() {
 #ifdef USE_JEMALLOC
     size_t value = 0;
     size_t sz = sizeof(value);
-    jemallctl("prof.active", &value, &sz, nullptr, 0);
+    mallctl("prof.active", &value, &sz, nullptr, 0);
     return value;
 #else
     return false;
diff --git a/be/src/util/mem_info.cpp b/be/src/util/mem_info.cpp
index fef10e679e6..78a65631f25 100644
--- a/be/src/util/mem_info.cpp
+++ b/be/src/util/mem_info.cpp
@@ -101,7 +101,7 @@ void MemInfo::refresh_allocator_mem() {
     // the current epoch number, which might be useful to log as a sanity 
check.
     uint64_t epoch = 0;
     size_t sz = sizeof(epoch);
-    jemallctl("epoch", &epoch, &sz, &epoch, sz);
+    mallctl("epoch", &epoch, &sz, &epoch, sz);
 
     // Number of extents of the given type in this arena in the bucket 
corresponding to page size index.
     // Large size class starts at 16384, the extents have three sizes before 
16384: 4096, 8192, and 12288, so + 3
diff --git a/be/src/util/mem_info.h b/be/src/util/mem_info.h
index c635b96a5d2..833cef30f5a 100644
--- a/be/src/util/mem_info.h
+++ b/be/src/util/mem_info.h
@@ -100,7 +100,7 @@ public:
 #ifdef USE_JEMALLOC
         size_t value = 0;
         size_t sz = sizeof(value);
-        if (jemallctl(name.c_str(), &value, &sz, nullptr, 0) == 0) {
+        if (mallctl(name.c_str(), &value, &sz, nullptr, 0) == 0) {
             return value;
         }
 #endif
@@ -111,7 +111,7 @@ public:
 #ifdef USE_JEMALLOC
         unsigned value = 0;
         size_t sz = sizeof(value);
-        if (jemallctl(name.c_str(), &value, &sz, nullptr, 0) == 0) {
+        if (mallctl(name.c_str(), &value, &sz, nullptr, 0) == 0) {
             return value;
         }
 #endif
@@ -143,8 +143,8 @@ public:
         if (config::enable_je_purge_dirty_pages) {
             try {
                 // Purge all unused dirty pages for arena <i>, or for all 
arenas if <i> equals MALLCTL_ARENAS_ALL.
-                int err = jemallctl(fmt::format("arena.{}.purge", 
MALLCTL_ARENAS_ALL).c_str(),
-                                    nullptr, nullptr, nullptr, 0);
+                int err = mallctl(fmt::format("arena.{}.purge", 
MALLCTL_ARENAS_ALL).c_str(),
+                                  nullptr, nullptr, nullptr, 0);
                 if (err) {
                     LOG(WARNING) << "Jemalloc purge all unused dirty pages 
failed";
                 }
@@ -163,7 +163,7 @@ public:
 #ifdef USE_JEMALLOC
         constexpr size_t TCACHE_LIMIT = (1ULL << 30); // 1G
         if (allocator_cache_mem() - je_dirty_pages_mem() > TCACHE_LIMIT) {
-            int err = jemallctl("thread.tcache.flush", nullptr, nullptr, 
nullptr, 0);
+            int err = mallctl("thread.tcache.flush", nullptr, nullptr, 
nullptr, 0);
             if (err) {
                 LOG(WARNING) << "Jemalloc thread.tcache.flush failed";
             }
diff --git a/be/src/vec/common/allocator.h b/be/src/vec/common/allocator.h
index 39197c75f92..1e791148f64 100644
--- a/be/src/vec/common/allocator.h
+++ b/be/src/vec/common/allocator.h
@@ -109,7 +109,7 @@ public:
 
     static void release_unused() {
 #if defined(USE_JEMALLOC)
-        jemallctl(fmt::format("arena.{}.purge", MALLCTL_ARENAS_ALL).c_str(), 
NULL, NULL, NULL, 0);
+        mallctl(fmt::format("arena.{}.purge", MALLCTL_ARENAS_ALL).c_str(), 
NULL, NULL, NULL, 0);
 #endif // defined(USE_JEMALLOC)
     }
 };
diff --git a/thirdparty/build-thirdparty.sh b/thirdparty/build-thirdparty.sh
index 93ec4fb7da8..2cf6294aa00 100755
--- a/thirdparty/build-thirdparty.sh
+++ b/thirdparty/build-thirdparty.sh
@@ -1523,8 +1523,10 @@ build_jemalloc() {
         WITH_LG_PAGE=''
     fi
 
+    # CFLAGS="${cflags}" ../configure --prefix="${TP_INSTALL_DIR}" 
--with-install-suffix="_doris" "${WITH_LG_PAGE}" \
+    #     --with-jemalloc-prefix=je --enable-prof --disable-cxx 
--disable-libdl --disable-shared
     CFLAGS="${cflags}" ../configure --prefix="${TP_INSTALL_DIR}" 
--with-install-suffix="_doris" "${WITH_LG_PAGE}" \
-        --with-jemalloc-prefix=je --enable-prof --disable-cxx --disable-libdl 
--disable-shared
+        --enable-prof --disable-libdl --disable-shared
 
     make -j "${PARALLEL}"
     make install


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

Reply via email to