Page MenuHomePhabricator

[asan] Disable fast unwinder on arm-linux-gnueabi with thumb

Authored by zatrazz on Jul 3 2020, 7:55 AM.



ARM thumb/thumb2 frame pointer is inconsistent on GCC and Clang [1]
and fast-unwider is also unreliable with mixing arm and thumb code [2].

The fast unwinder ARM hacks to probe and compare the frame-pointer
in different stack layout position works reliable only on a system where
all the libraries are built in arm mode (either with gcc or clang).

However when mixing objects built with different abi mode the
fast unwinder is still problematic. The quarantine_size_mb.cpp
still fails on ARM on system with libraries built with thumb (Ubuntu
bionic for instance) so make is pass clean this patch forces it to
use the slow unwinder is to avoid a leak warning triggered by the
helper quarantine thread creation (the allocation is done by glibc
pthread_create). Without proper stack frame information libsanitizer
can not apply the expected suppresion in this case.

This should fix BZ#44158, however the leak sanitizier is still
unreliable on most distros where the system compiler defaults to
use thumb.


Diff Detail

Unit TestsFailed

740 mslinux > SanitizerCommon-asan-x86_64-Linux.Linux::Unknown Unit Message ("")
Script: -- : 'RUN: at line 1'; /mnt/disks/ssd0/agent/llvm-project/build/./bin/clang --driver-mode=g++ -gline-tables-only -fsanitize=address -m64 -ldl -std=c++11 -O0 -g /mnt/disks/ssd0/agent/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/protoent.cpp -o /mnt/disks/ssd0/agent/llvm-project/build/projects/compiler-rt/test/sanitizer_common/asan-x86_64-Linux/Linux/Output/protoent.cpp.tmp
510 mslinux > SanitizerCommon-lsan-x86_64-Linux.Linux::Unknown Unit Message ("")
Script: -- : 'RUN: at line 1'; /mnt/disks/ssd0/agent/llvm-project/build/./bin/clang --driver-mode=g++ -gline-tables-only -fsanitize=leak -m64 -ldl -std=c++11 -O0 -g /mnt/disks/ssd0/agent/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/protoent.cpp -o /mnt/disks/ssd0/agent/llvm-project/build/projects/compiler-rt/test/sanitizer_common/lsan-x86_64-Linux/Linux/Output/protoent.cpp.tmp
620 mslinux > SanitizerCommon-msan-x86_64-Linux.Linux::Unknown Unit Message ("")
Script: -- : 'RUN: at line 1'; /mnt/disks/ssd0/agent/llvm-project/build/./bin/clang --driver-mode=g++ -gline-tables-only -fsanitize=memory -m64 -ldl -std=c++11 -O0 -g /mnt/disks/ssd0/agent/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/protoent.cpp -o /mnt/disks/ssd0/agent/llvm-project/build/projects/compiler-rt/test/sanitizer_common/msan-x86_64-Linux/Linux/Output/protoent.cpp.tmp
900 mslinux > SanitizerCommon-tsan-x86_64-Linux.Linux::Unknown Unit Message ("")
Script: -- : 'RUN: at line 1'; /mnt/disks/ssd0/agent/llvm-project/build/./bin/clang --driver-mode=g++ -gline-tables-only -fsanitize=thread -m64 -ldl -std=c++11 -O0 -g /mnt/disks/ssd0/agent/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/protoent.cpp -o /mnt/disks/ssd0/agent/llvm-project/build/projects/compiler-rt/test/sanitizer_common/tsan-x86_64-Linux/Linux/Output/protoent.cpp.tmp
570 mslinux > SanitizerCommon-ubsan-x86_64-Linux.Linux::Unknown Unit Message ("")
Script: -- : 'RUN: at line 1'; /mnt/disks/ssd0/agent/llvm-project/build/./bin/clang --driver-mode=g++ -gline-tables-only -fsanitize=undefined -m64 -ldl -std=c++11 -O0 -g /mnt/disks/ssd0/agent/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/protoent.cpp -o /mnt/disks/ssd0/agent/llvm-project/build/projects/compiler-rt/test/sanitizer_common/ubsan-x86_64-Linux/Linux/Output/protoent.cpp.tmp

Event Timeline

zatrazz created this revision.Jul 3 2020, 7:55 AM

Is unwinding actually broken on an all-clang, all-thumb system?

Is unwinding actually broken on an all-clang, all-thumb system?

The issue is when instrumented objects interact with gcc object,, for instance running instrumented binaries on usual distros like Ubuntu. I haven't tested on a all-clang/all-thumb system, but from my understanding is clang thumb use the FP similar no arm mode (differerent than gcc), so it should work.

Is this patch still needed?

Is this patch still needed?

It is to at least make the unwinder not triggering testcase failures on some arm-linux-gnu distros [1]. The fast-unwinder on ARM does not work correctly when unwinding any thumb code built code by gcc, so it would potentially fail on some scenarios (for instance if system libraries or gcc-build ones call malloc). It should be mitigated by 'fast_unwind_on_check=0' and/or 'fast_unwind_on_malloc=0'.

This issues has come up multiple times and compiler-rt developers either state that Android (which is now built with clang) and clang built objects works and that _Unwind based unwind is too slow to be usable. I think we should at least document this issues with gcc built with thumb support and the possible mitigations and tradeoffs.


eugenis accepted this revision.Aug 24 2020, 9:29 AM


This revision is now accepted and ready to land.Aug 24 2020, 9:29 AM
vitalybuka accepted this revision.Aug 24 2020, 6:25 PM
zatrazz abandoned this revision.Oct 7 2020, 5:14 AM