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

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


The following commit(s) were added to refs/heads/branch-4.1 by this push:
     new f2d89b84f75 branch-4.1: [fix](be) avoid LeakSanitizer false positive 
on BE startup failure #64802 (#64916)
f2d89b84f75 is described below

commit f2d89b84f75558118a33e09863d03d3fbca68b6e
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Mon Jun 29 15:06:55 2026 +0800

    branch-4.1: [fix](be) avoid LeakSanitizer false positive on BE startup 
failure #64802 (#64916)
    
    Cherry-picked from #64802
    
    Co-authored-by: Mingyu Chen (Rayner) <[email protected]>
---
 be/src/service/doris_main.cpp | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/be/src/service/doris_main.cpp b/be/src/service/doris_main.cpp
index fd534bc77f0..83d4dd5dc31 100644
--- a/be/src/service/doris_main.cpp
+++ b/be/src/service/doris_main.cpp
@@ -314,6 +314,21 @@ struct Checker {
 #endif
         ;
 
+// A startup failure that happens after ExecEnv::init() has run must terminate 
the
+// process the same way normal shutdown does (see the _exit(0) at the end of 
main):
+// in the default mode we _exit() immediately, skipping global destructors and 
the
+// LeakSanitizer atexit check. Init-time singletons (e.g. the internal workload
+// group's task scheduler) intentionally live for the whole process lifetime, 
so
+// running the leak check on this abnormal-exit path reports them as 
false-positive
+// leaks. enable_graceful_exit_check is honored so memleak-check mode still 
runs LSAN.
+[[noreturn]] static void exit_on_startup_failure() {
+    google::FlushLogFiles(google::GLOG_INFO);
+    if (!doris::config::enable_graceful_exit_check) {
+        _exit(1);
+    }
+    exit(1);
+}
+
 int main(int argc, char** argv) {
     doris::signal::InstallFailureSignalHandler();
     // create StackTraceCache Instance, at the beginning, other static 
destructors may use.
@@ -598,7 +613,7 @@ int main(int argc, char** argv) {
     status = doris::ExecEnv::init(doris::ExecEnv::GetInstance(), paths, 
spill_paths, broken_paths);
     if (status != Status::OK()) {
         std::cerr << "failed to init doris storage engine, res=" << status;
-        return 0;
+        exit_on_startup_failure();
     }
 
     // Start concurrency stats manager
@@ -614,7 +629,7 @@ int main(int argc, char** argv) {
         if (!status.ok()) {
             std::cerr << msg << '\n';
             service->stop_works();
-            exit(-1);
+            exit_on_startup_failure();
         }
     };
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to