Skip to content

Commit fe1006b

Browse files
authored
[TSan] fix crash when symbolize on darwin platforms (#99441)
The `dli_sname` filed in `Dl_info` may be `NULL`, which could cause a crash
1 parent 08a72cb commit fe1006b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace __sanitizer {
3030
bool DlAddrSymbolizer::SymbolizePC(uptr addr, SymbolizedStack *stack) {
3131
Dl_info info;
3232
int result = dladdr((const void *)addr, &info);
33-
if (!result) return false;
33+
if (!result || !info.dli_sname) return false;
3434

3535
// Compute offset if possible. `dladdr()` doesn't always ensure that `addr >=
3636
// 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) {
5151
bool DlAddrSymbolizer::SymbolizeData(uptr addr, DataInfo *datainfo) {
5252
Dl_info info;
5353
int result = dladdr((const void *)addr, &info);
54-
if (!result) return false;
54+
if (!result || !info.dli_sname) return false;
5555
const char *demangled = DemangleSwiftAndCXX(info.dli_sname);
5656
if (!demangled)
5757
demangled = info.dli_sname;

0 commit comments

Comments
 (0)