[compiler-rt] [TSan] fix crash when symbolize on darwin platforms (PR #99441)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 18 00:17:22 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: None (pudge62)
<details>
<summary>Changes</summary>
The `dli_sname` filed in `Dl_info` may be `NULL`, which could cause a crash
---
Full diff: https://github.com/llvm/llvm-project/pull/99441.diff
1 Files Affected:
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cpp (+2-2)
``````````diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cpp
index f1cc0b5e1e8ac..88536fc4e6222 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cpp
@@ -30,7 +30,7 @@ namespace __sanitizer {
bool DlAddrSymbolizer::SymbolizePC(uptr addr, SymbolizedStack *stack) {
Dl_info info;
int result = dladdr((const void *)addr, &info);
- if (!result) return false;
+ if (!result || !info.dli_sname) return false;
// Compute offset if possible. `dladdr()` doesn't always ensure that `addr >=
// sym_addr` so only compute the offset when this holds. Failure to find the
@@ -51,7 +51,7 @@ bool DlAddrSymbolizer::SymbolizePC(uptr addr, SymbolizedStack *stack) {
bool DlAddrSymbolizer::SymbolizeData(uptr addr, DataInfo *datainfo) {
Dl_info info;
int result = dladdr((const void *)addr, &info);
- if (!result) return false;
+ if (!result || !info.dli_sname) return false;
const char *demangled = DemangleSwiftAndCXX(info.dli_sname);
if (!demangled)
demangled = info.dli_sname;
``````````
</details>
https://github.com/llvm/llvm-project/pull/99441
More information about the llvm-commits
mailing list