Page MenuHomePhabricator

[asan_symbolize] Avoid blocking when llvm-symbolizer is installed as addr2line
ClosedPublic

Authored by arichardson on Jul 26 2019, 1:28 AM.

Details

Summary

Currently, llvm-symbolizer will print -1 when presented with -1 and not
print a second line. In that case we will block for ever trying to read
the file name. This also happens for non-existent files, in which case GNU
addr2line exits immediate, but llvm-symbolizer does not (see
https://llvm.org/PR42754). While touching these lines, I also added some
more debug logging to help diagnose this and potential future issues.

Diff Detail

Repository
rL LLVM

Event Timeline

arichardson created this revision.Jul 26 2019, 1:28 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 26 2019, 1:28 AM
Herald added subscribers: llvm-commits, Restricted Project, kubamracek. · View Herald Transcript

Ping? This breaks unit test when building with -DLLVM_INSTALL_BINUTILS_SYMLINKS=ON

This revision is now accepted and ready to land.Aug 23 2019, 10:47 AM
This revision was automatically updated to reflect the committed changes.

Now it breaks http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/23108/steps/check-asan%20in%20gcc%20build/logs/stdio

FAIL: AddressSanitizer-i386-linux :: TestCases/Posix/asan-symbolize-bad-path.cpp (530 of 1412)
******************** TEST 'AddressSanitizer-i386-linux :: TestCases/Posix/asan-symbolize-bad-path.cpp' FAILED ********************
Script:
--
: 'RUN: at line 3';   echo '#0 0xabcdabcd (/b/sanitizer-x86_64-linux/build/clang_build/projects/compiler-rt/test/asan/I386LinuxConfig/TestCases/Posix/Output/asan-symbolize-bad-path.cpp.tmp/bad/path+0x1234)' | /usr/bin/python /b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py  | FileCheck /b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Posix/asan-symbolize-bad-path.cpp -check-prefix CHECK-BAD-FILE
: 'RUN: at line 8';      /b/sanitizer-x86_64-linux/build/clang_build/./bin/clang  --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only  -m32  -O0 /b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Posix/asan-symbolize-bad-path.cpp -o /b/sanitizer-x86_64-linux/build/clang_build/projects/compiler-rt/test/asan/I386LinuxConfig/TestCases/Posix/Output/asan-symbolize-bad-path.cpp.tmp
: 'RUN: at line 9';   echo '#0 0xabcdabcd (/b/sanitizer-x86_64-linux/build/clang_build/projects/compiler-rt/test/asan/I386LinuxConfig/TestCases/Posix/Output/asan-symbolize-bad-path.cpp.tmp+0x0)' | /usr/bin/python /b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py  | FileCheck /b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Posix/asan-symbolize-bad-path.cpp -check-prefix CHECK-BAD-ADDR
--
Exit Code: 2

Command Output (stderr):
--
LLVMSymbolizer: error reading file: No such file or directory
addr2line: '/b/sanitizer-x86_64-linux/build/clang_build/projects/compiler-rt/test/asan/I386LinuxConfig/TestCases/Posix/Output/asan-symbolize-bad-path.cpp.tmp/bad/path': No such file
Traceback (most recent call last):
  File "/b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py", line 1053, in <module>
    loop.process_logfile()
  File "/b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py", line 472, in process_logfile
    processed = self.process_line(line)
  File "/b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py", line 522, in process_line_posix
    symbolized_line = self.symbolize_address(addr, binary, offset, arch)
  File "/b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py", line 451, in symbolize_address
    result = symbolizers[binary].symbolize(addr, binary, offset)
  File "/b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py", line 290, in symbolize
    result = symbolizer.symbolize(addr, binary, offset)
  File "/b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py", line 202, in symbolize
    except BrokenPipeError:
NameError: global name 'BrokenPipeError' is not defined
FileCheck error: '-' is empty.
FileCheck command line:  FileCheck /b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Posix/asan-symbolize-bad-path.cpp -check-prefix CHECK-BAD-FILE

--

********************
Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 
FAIL: AddressSanitizer-x86_64-linux :: TestCases/Posix/asan-symbolize-bad-path.cpp (1003 of 1412)
******************** TEST 'AddressSanitizer-x86_64-linux :: TestCases/Posix/asan-symbolize-bad-path.cpp' FAILED ********************
Script:
--
: 'RUN: at line 3';   echo '#0 0xabcdabcd (/b/sanitizer-x86_64-linux/build/clang_build/projects/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Posix/Output/asan-symbolize-bad-path.cpp.tmp/bad/path+0x1234)' | /usr/bin/python /b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py  | FileCheck /b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Posix/asan-symbolize-bad-path.cpp -check-prefix CHECK-BAD-FILE
: 'RUN: at line 8';      /b/sanitizer-x86_64-linux/build/clang_build/./bin/clang  --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only  -m64  -O0 /b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Posix/asan-symbolize-bad-path.cpp -o /b/sanitizer-x86_64-linux/build/clang_build/projects/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Posix/Output/asan-symbolize-bad-path.cpp.tmp
: 'RUN: at line 9';   echo '#0 0xabcdabcd (/b/sanitizer-x86_64-linux/build/clang_build/projects/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Posix/Output/asan-symbolize-bad-path.cpp.tmp+0x0)' | /usr/bin/python /b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py  | FileCheck /b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Posix/asan-symbolize-bad-path.cpp -check-prefix CHECK-BAD-ADDR
--
Exit Code: 1

Command Output (stderr):
--
LLVMSymbolizer: error reading file: No such file or directory
addr2line: '/b/sanitizer-x86_64-linux/build/clang_build/projects/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Posix/Output/asan-symbolize-bad-path.cpp.tmp/bad/path': No such file
/b/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Posix/asan-symbolize-bad-path.cpp:4:20: error: CHECK-BAD-FILE: expected string not found in input
// CHECK-BAD-FILE: #0 0xabcdabcd in ?? ??:0
                   ^
<stdin>:1:2: note: scanning from here
 #0 0xabcdabcd in
 ^

--

********************
Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
Testing Time: 27.72s
********************
Failing Tests (2):
    AddressSanitizer-i386-linux :: TestCases/Posix/asan-symbolize-bad-path.cpp
    AddressSanitizer-x86_64-linux :: TestCases/Posix/asan-symbolize-bad-path.cpp

  Expected Passes    : 1055
  Expected Failures  : 2
  Unsupported Tests  : 353
  Unexpected Failures: 2
vitalybuka added inline comments.Aug 26 2019, 7:03 PM
compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py
202

Probably

except socket.error as e:
    if e.errno == errno.EPIPE:

I believe I fixed this problem in https://reviews.llvm.org/rL369929

It seems like address %t+0x0 is valid on that builder. Maybe it defaults to -pie. Should be fixable by using an address that is more likely to be invalid.

vitalybuka added a comment.EditedAug 27 2019, 12:02 AM

I believe I fixed this problem in https://reviews.llvm.org/rL369929

It seems like address %t+0x0 is valid on that builder. Maybe it defaults to -pie. Should be fixable by using an address that is more likely to be invalid.

But it's still a problem in python code which is not going to work on on python 2.7
https://llvm.org/docs/GettingStarted.html promise 2.7 support

I believe I fixed this problem in https://reviews.llvm.org/rL369929

It seems like address %t+0x0 is valid on that builder. Maybe it defaults to -pie. Should be fixable by using an address that is more likely to be invalid.

But it's still a problem in python code which is not going to work on on python 2.7

I ran all tests with python 2.7 so I have no idea why it worked. Seems like I never triggered the bad path. Will fix to be python2.7 compatible asap.