[Lldb-commits] [lldb] [lldb] Fix TSan report on Linux (PR #179115)

via lldb-commits lldb-commits at lists.llvm.org
Sun Feb 1 07:26:31 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Sergei Druzhkov (DrSergei)

<details>
<summary>Changes</summary>

Linux uses 0 for `RTLD_DEFAULT` opposite to macOS and BSD systems (they use -2).

Before:
<img width="1271" height="742" alt="before" src="https://github.com/user-attachments/assets/870cc524-c39c-4717-9a65-d7b66ded3280" />

After:
<img width="1271" height="740" alt="after" src="https://github.com/user-attachments/assets/088ea43c-2cfd-4135-8af9-54edd4ae32ff" />


---
Full diff: https://github.com/llvm/llvm-project/pull/179115.diff


3 Files Affected:

- (modified) lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp (+12-2) 
- (modified) lldb/test/API/functionalities/tsan/thread_leak/TestTsanThreadLeak.py (-4) 
- (modified) lldb/test/API/functionalities/tsan/thread_numbers/TestTsanThreadNumbers.py (-4) 


``````````diff
diff --git a/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
index 04dd825519d35..53299dec0923f 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
+++ b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
@@ -88,8 +88,18 @@ extern "C"
     // TODO: dlsym won't work on Windows.
     void *dlsym(void* handle, const char* symbol);
     int (*ptr__tsan_get_report_loc_object_type)(void *report, unsigned long idx, const char **object_type);
-}
+)"
+#if defined(__linux__)
+R"(
+    void *const RTLD_DEFAULT = (void *)0;
+  }
+)";
+#else
+R"(
+    void *const RTLD_DEFAULT = (void *)-2;
+  }
 )";
+#endif
 
 const char *thread_sanitizer_retrieve_report_data_command = R"(
 
@@ -161,7 +171,7 @@ struct {
     } unique_tids[REPORT_ARRAY_SIZE];
 } t = {0};
 
-ptr__tsan_get_report_loc_object_type = (typeof(ptr__tsan_get_report_loc_object_type))(void *)dlsym((void*)-2 /*RTLD_DEFAULT*/, "__tsan_get_report_loc_object_type");
+ptr__tsan_get_report_loc_object_type = (typeof(ptr__tsan_get_report_loc_object_type))(void *)dlsym(RTLD_DEFAULT, "__tsan_get_report_loc_object_type");
 
 t.report = __tsan_get_current_report();
 __tsan_get_report_data(t.report, &t.description, &t.report_count, &t.stack_count, &t.mop_count, &t.loc_count, &t.mutex_count, &t.thread_count, &t.unique_tid_count, t.sleep_trace, REPORT_TRACE_SIZE);
diff --git a/lldb/test/API/functionalities/tsan/thread_leak/TestTsanThreadLeak.py b/lldb/test/API/functionalities/tsan/thread_leak/TestTsanThreadLeak.py
index 2f5cceb7873c7..fe995935ea4ef 100644
--- a/lldb/test/API/functionalities/tsan/thread_leak/TestTsanThreadLeak.py
+++ b/lldb/test/API/functionalities/tsan/thread_leak/TestTsanThreadLeak.py
@@ -9,10 +9,6 @@
 
 
 class TsanThreadLeakTestCase(TestBase):
-    @expectedFailureAll(
-        oslist=["linux"],
-        bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)",
-    )
     @expectedFailureNetBSD
     @skipIfFreeBSD  # llvm.org/pr21136 runtimes not yet available by default
     @skipIfRemote
diff --git a/lldb/test/API/functionalities/tsan/thread_numbers/TestTsanThreadNumbers.py b/lldb/test/API/functionalities/tsan/thread_numbers/TestTsanThreadNumbers.py
index 8fc1ae64c267e..68e9a064793bb 100644
--- a/lldb/test/API/functionalities/tsan/thread_numbers/TestTsanThreadNumbers.py
+++ b/lldb/test/API/functionalities/tsan/thread_numbers/TestTsanThreadNumbers.py
@@ -10,10 +10,6 @@
 
 
 class TsanThreadNumbersTestCase(TestBase):
-    @expectedFailureAll(
-        oslist=["linux"],
-        bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)",
-    )
     @expectedFailureNetBSD
     @skipIfFreeBSD  # llvm.org/pr21136 runtimes not yet available by default
     @skipIfRemote

``````````

</details>


https://github.com/llvm/llvm-project/pull/179115


More information about the lldb-commits mailing list