[compiler-rt] fe1006b - [TSan] fix crash when symbolize on darwin platforms (#99441)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 2 00:31:54 PDT 2024


Author: pudge62
Date: 2024-09-02T09:31:51+02:00
New Revision: fe1006b7f25258742173304c7c32e891be31d14e

URL: https://github.com/llvm/llvm-project/commit/fe1006b7f25258742173304c7c32e891be31d14e
DIFF: https://github.com/llvm/llvm-project/commit/fe1006b7f25258742173304c7c32e891be31d14e.diff

LOG: [TSan] fix crash when symbolize on darwin platforms (#99441)

The `dli_sname` filed in `Dl_info` may be `NULL`, which could cause a
crash

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cpp
index f1cc0b5e1e8ac0..88536fc4e6222f 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;


        


More information about the llvm-commits mailing list