Skip to content

Commit

Permalink
[TSan] fix crash when symbolize on darwin platforms (#99441)
Browse files Browse the repository at this point in the history
The `dli_sname` filed in `Dl_info` may be `NULL`, which could cause a
crash
  • Loading branch information
pudge62 authored Sep 2, 2024
1 parent 08a72cb commit fe1006b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit fe1006b

Please sign in to comment.