llvm-project/compiler-rt/lib
Dan Liew 923cf890d1 Avoid failing a CHECK in `DlAddrSymbolizer::SymbolizePC`.
Summary:
It turns out the `CHECK(addr >= reinterpret_cast<upt>(info.dli_saddr)`
can fail because on armv7s on iOS 9.3 `dladdr()` returns
`info.dli_saddr` with an address larger than the address we provided.

We should avoid crashing here because crashing in the middle of reporting
an issue is very unhelpful. Instead we now try to compute a function offset
if the value we get back from `dladdr()` looks sane, otherwise we don't
set the function offset.

A test case is included. It's basically a slightly modified version of
the existing `test/sanitizer_common/TestCases/Darwin/symbolizer-function-offset-dladdr.cpp`
test case that doesn't run on iOS devices right now.

More details:

In the concrete scenario on armv7s `addr` is `0x2195c870` and the returned
`info.dli_saddr` is `0x2195c871`.

This what LLDB says when disassembling the code.

```
(lldb) dis -a 0x2195c870
libdyld.dylib`<redacted>:
    0x2195c870 <+0>: nop
    0x2195c872 <+2>: blx    0x2195c91c                ; symbol stub for: exit
    0x2195c876 <+6>: trap
```

The value returned by `dladdr()` doesn't make sense because it points
into the middle of a instruction.

There might also be other bugs lurking here because I noticed that the PCs we
gather during stackunwinding (before changing them with
`StackTrace::GetPreviousInstructionPc()`) look a little suspicious (e.g.  the
PC stored for the frame with fail to symbolicate is 0x2195c873) as they don't
look properly aligned. This probably warrants further investigation in the future.

rdar://problem/65621511

Reviewers: kubamracek, yln

Subscribers: kristof.beyls, llvm-commits, #sanitizers

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D84262
2020-07-21 12:49:50 -07:00
..
BlocksRuntime
asan [compiler-rt][asan] decommit shadow memory for unmaps in fuchsia. 2020-07-21 11:07:47 -07:00
builtins cmake list formatting fix 2020-07-16 18:29:48 -04:00
cfi Improve error message when '=' is missing in {ASAN,...}_OPTIONS. 2019-06-15 01:37:14 +00:00
crt [cmake] Strip quotes in compiler-rt/lib/crt; error if checks fail 2020-03-09 15:52:39 -07:00
dfsan [dfsan] Remove realloc from done_abilist.txt 2020-05-05 22:32:45 -07:00
fuzzer Corrected __libfuzzer_is_present symbol inclusion for MSVC x86 32-bit 2020-07-17 18:29:47 -07:00
gwp_asan [GWP-ASan] Split the unwinder into segv/non-segv. 2020-07-21 08:25:37 -07:00
hwasan [compiler-rt][asan][hwasan] Refactor shadow setup into sanitizer_common (NFCI) 2020-07-16 11:47:05 -07:00
interception Fix check-interception link error in compiler-rt debug mode 2019-10-10 23:30:54 +00:00
lsan [LSan] Enable for SystemZ 2020-06-16 13:45:29 +02:00
msan [MSAN] Pass Origin by parameter to __msan_warning functions 2020-06-15 17:49:18 -07:00
profile [compiler-rt] Use -nostdinc++ in clang_rt.profile to avoid including C++ headers 2020-07-21 09:14:33 -04:00
safestack compiler-rt: Rename .cc file in lib/{interception/tests,safestack} to .cpp 2019-08-01 13:56:52 +00:00
sanitizer_common Avoid failing a CHECK in `DlAddrSymbolizer::SymbolizePC`. 2020-07-21 12:49:50 -07:00
scudo [GWP-ASan] Split the unwinder into segv/non-segv. 2020-07-21 08:25:37 -07:00
stats compiler-rt: Rename .cc file in lib/{dfsan,stats,ubsan_minimal} to .cpp 2019-08-01 12:41:23 +00:00
tsan [tsan][go] Fix for missing symbols needed by GotsanRuntimeCheck 2020-07-16 17:01:15 -06:00
ubsan Update ubsan_interface.inc for D71491 (second try) 2020-07-14 11:16:11 -07:00
ubsan_minimal [ubsan] Check implicit casts in ObjC for-in statements 2020-07-13 15:11:18 -07:00
xray [xray] Option to omit the function index 2020-06-17 13:49:01 -04:00
CMakeLists.txt scudo: Add support for diagnosing memory errors when memory tagging is enabled. 2020-04-17 17:26:30 -07:00