HomePhabricator

[asan_symbolize] Fix bug where the frame counter was not incremented.

Description

[asan_symbolize] Fix bug where the frame counter was not incremented.

Summary:
This bug occurred when a plug-in requested that a binary not be
symbolized while the script is trying to symbolize a stack frame. In
this case self.frame_no would not be incremented. This would cause
subsequent stack frames that are symbolized to be incorrectly numbered.

To fix this get_symbolized_lines() has been modified to take an
argument that indicates whether the stack frame counter should
incremented. In process_line_posix() get_symbolized_lines(None, ...)
is now used in in the case where we don't want to symbolize a line so
that we can keep the frame counter increment in a single function.

A test case is included. The test uses a dummy plugin that always asks
asan_symbolize.py script to not symbolize the first binary that the
script asks about. Prior to the patch this would cause the output to
script to look something like

#0 0x0
#0 0x0 in do_access
#1 0x0 in main

rdar://problem/49476995

Reviewers: kubamracek, yln, samsonov, dvyukov, vitalybuka

Subscribers: #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

Differential Revision: https://reviews.llvm.org/D65495

Details

Committed
delcypherAug 8 2019, 5:52 PM
Differential Revision
D65495: [asan_symbolize] Fix bug where the frame counter was not incremented.
Parents
rL368372: [monorepo] Pass lldb src with -L to CMake
Branches
Unknown
Tags
Unknown

Event Timeline

hctim added a subscriber: hctim.Aug 9 2019, 11:47 AM

Looks like this may have broken the sanitizer-android buildbot: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/builds/23393

******************** TEST 'AddressSanitizer-i386-android :: TestCases/Posix/asan_symbolize_script/plugin_wrong_frame_number_bug.cpp' FAILED ********************
Script:
--
: 'RUN: at line 4';     /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm/projects/compiler-rt/test/sanitizer_common/android_commands/android_compile.py  /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build64/bin/clang  --driver-mode=g++ -stdlib=libstdc++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only  -pie -fuse-ld=gold --target=i686-linux-android --sysroot=/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/standalone-i686/sysroot -B/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/standalone-i686  -shared-libasan -O0 -g /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm/projects/compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/plugin_wrong_frame_number_bug.cpp -o /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/compiler_rt_build_android_i686/test/asan/I386AndroidConfig/TestCases/Posix/asan_symbolize_script/Output/plugin_wrong_frame_number_bug.cpp.tmp
: 'RUN: at line 5';   env ASAN_OPTIONS=abort_on_error=0:symbolize=0 not  /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/compiler_rt_build_android_i686/test/asan/I386AndroidConfig/TestCases/Posix/asan_symbolize_script/Output/plugin_wrong_frame_number_bug.cpp.tmp DUMMY_ARG > /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/compiler_rt_build_android_i686/test/asan/I386AndroidConfig/TestCases/Posix/asan_symbolize_script/Output/plugin_wrong_frame_number_bug.cpp.tmp.asan_report 2>&1
: 'RUN: at line 6';   /usr/bin/python /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py  --log-level debug --log-dest /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/compiler_rt_build_android_i686/test/asan/I386AndroidConfig/TestCases/Posix/asan_symbolize_script/Output/plugin_wrong_frame_number_bug.cpp.tmp_debug_log_output.txt -l /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/compiler_rt_build_android_i686/test/asan/I386AndroidConfig/TestCases/Posix/asan_symbolize_script/Output/plugin_wrong_frame_number_bug.cpp.tmp.asan_report --plugins /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm/projects/compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/plugin_wrong_frame_number_bug.py > /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/compiler_rt_build_android_i686/test/asan/I386AndroidConfig/TestCases/Posix/asan_symbolize_script/Output/plugin_wrong_frame_number_bug.cpp.tmp.asan_report_sym
: 'RUN: at line 7';   FileCheck --input-file=/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/compiler_rt_build_android_i686/test/asan/I386AndroidConfig/TestCases/Posix/asan_symbolize_script/Output/plugin_wrong_frame_number_bug.cpp.tmp.asan_report_sym /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm/projects/compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/plugin_wrong_frame_number_bug.cpp
--
Exit Code: 1

Command Output (stderr):
--
LLVMSymbolizer: error reading file: No such file or directory
addr2line: '/data/local/tmp/Output/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/compiler_rt_build_android_i686/test/asan/I386AndroidConfig/TestCases/Posix/asan_symbolize_script/Output/plugin_wrong_frame_number_bug.cpp.tmp': No such file
LLVMSymbolizer: error reading file: No such file or directory
addr2line: '/system/lib/libc.so': No such file
LLVMSymbolizer: error reading file: No such file or directory
addr2line: '/data/local/tmp/Output/libclang_rt.asan-i686-android.so': No such file
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm/projects/compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/plugin_wrong_frame_number_bug.cpp:47:16: error: CHECK-NEXT: expected string not found in input
// CHECK-NEXT: #1 0x{{[0-9a-fA-F]+}} in do_access
               ^
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/compiler_rt_build_android_i686/test/asan/I386AndroidConfig/TestCases/Posix/asan_symbolize_script/Output/plugin_wrong_frame_number_bug.cpp.tmp.asan_report_sym:4:16: note: scanning from here
 #0 0xf2c267e0 (/data/local/tmp/Output/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/compiler_rt_build_android_i686/test/asan/I386AndroidConfig/TestCases/Posix/asan_symbolize_script/Output/plugin_wrong_frame_number_bug.cpp.tmp+0x7e0)
               ^
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/compiler_rt_build_android_i686/test/asan/I386AndroidConfig/TestCases/Posix/asan_symbolize_script/Output/plugin_wrong_frame_number_bug.cpp.tmp.asan_report_sym:16:2: note: possible intended match here
 #4 0xf29f232c in ?? ??:0
 ^

--