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

hellostephen 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 8b03038f5d2 [fix](test) fix death tests crash in multi-threaded UT 
binary (#61158)
8b03038f5d2 is described below

commit 8b03038f5d20f5302eb4ac71d91766667ef6d777
Author: Chenyang Sun <[email protected]>
AuthorDate: Mon Mar 9 19:15:34 2026 +0800

    [fix](test) fix death tests crash in multi-threaded UT binary (#61158)
    
    ASSERT_DEATH/EXPECT_DEATH to crash due to unsafe fork() in
    multi-threaded context.
    
    Fix: add GTEST_FLAG_SET(death_test_style, "threadsafe") so gtest uses
    fork+re-exec instead of plain fork, and setrlimit to suppress core dumps
    in death test child processes.
---
 .../storage/index/inverted/query_v2/phrase_prefix_query_test.cpp | 9 ++++++++-
 be/test/storage/storage_resource_test.cpp                        | 9 ++++++++-
 be/test/util/threadpool_test.cpp                                 | 5 +++++
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git 
a/be/test/storage/index/inverted/query_v2/phrase_prefix_query_test.cpp 
b/be/test/storage/index/inverted/query_v2/phrase_prefix_query_test.cpp
index ced7784982a..4016008d631 100644
--- a/be/test/storage/index/inverted/query_v2/phrase_prefix_query_test.cpp
+++ b/be/test/storage/index/inverted/query_v2/phrase_prefix_query_test.cpp
@@ -19,6 +19,7 @@
 
 #include <CLucene.h>
 #include <gtest/gtest.h>
+#include <sys/resource.h>
 
 #include <memory>
 #include <roaring/roaring.hh>
@@ -199,7 +200,13 @@ TEST_F(PhrasePrefixQueryV2Test, empty_terms_throws) {
     std::vector<TermInfo> empty_terms;
 
     // Constructor asserts !terms.empty(), which aborts in debug builds.
-    EXPECT_DEATH({ PhrasePrefixQuery q(ctx, field, empty_terms); }, "");
+    GTEST_FLAG_SET(death_test_style, "threadsafe");
+    EXPECT_DEATH(({
+                     struct rlimit core_limit {};
+                     setrlimit(RLIMIT_CORE, &core_limit);
+                     PhrasePrefixQuery q(ctx, field, empty_terms);
+                 }),
+                 "");
 }
 
 // --- PhrasePrefixWeight scorer: phrase + prefix match ---
diff --git a/be/test/storage/storage_resource_test.cpp 
b/be/test/storage/storage_resource_test.cpp
index 38e8e38f934..e0ebdc7d75d 100644
--- a/be/test/storage/storage_resource_test.cpp
+++ b/be/test/storage/storage_resource_test.cpp
@@ -17,6 +17,7 @@
 
 #include <gen_cpp/cloud.pb.h>
 #include <gtest/gtest.h>
+#include <sys/resource.h>
 
 #include "io/fs/s3_file_system.h"
 #include "storage/rowset/rowset_meta.h"
@@ -78,7 +79,13 @@ TEST(StorageResourceTest, RemotePath) {
               "data/611/10005/10006.13.meta");
 
     path_format->set_path_version(2);
-    ASSERT_DEATH(StorageResource(res.value(), storage_vault_pb.path_format()), 
"unknown");
+    GTEST_FLAG_SET(death_test_style, "threadsafe");
+    ASSERT_DEATH(({
+                     struct rlimit core_limit {};
+                     setrlimit(RLIMIT_CORE, &core_limit);
+                     StorageResource(res.value(), 
storage_vault_pb.path_format());
+                 }),
+                 "unknown");
 }
 
 TEST(StorageResourceTest, ParseTabletIdFromPath) {
diff --git a/be/test/util/threadpool_test.cpp b/be/test/util/threadpool_test.cpp
index f071fce1054..8107c6180a2 100644
--- a/be/test/util/threadpool_test.cpp
+++ b/be/test/util/threadpool_test.cpp
@@ -23,6 +23,7 @@
 #include <gtest/gtest-param-test.h>
 #include <gtest/gtest-test-part.h>
 #include <sched.h>
+#include <sys/resource.h>
 #include <unistd.h>
 
 #include <atomic>
@@ -334,6 +335,8 @@ TEST_F(ThreadPoolTest, TestDeadlocks) {
 #endif
     EXPECT_DEATH(
             {
+                struct rlimit core_limit {};
+                setrlimit(RLIMIT_CORE, &core_limit);
                 EXPECT_TRUE(rebuild_pool_with_min_max(1, 1).ok());
                 EXPECT_TRUE(_pool->submit_func([pool = _pool.get()]() { 
pool->shutdown(); }).ok());
                 _pool->wait();
@@ -342,6 +345,8 @@ TEST_F(ThreadPoolTest, TestDeadlocks) {
 
     EXPECT_DEATH(
             {
+                struct rlimit core_limit {};
+                setrlimit(RLIMIT_CORE, &core_limit);
                 EXPECT_TRUE(rebuild_pool_with_min_max(1, 1).ok());
                 EXPECT_TRUE(_pool->submit_func([pool = _pool.get()]() { 
pool->wait(); }).ok());
                 _pool->wait();


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

Reply via email to