This fixes a bug in the ReadFromSymbolizer method of the Addr2LineProcess class; if the input is too large, the returned buffer will be null and will consequently fail the CHECK. The proposed fix is to simply check if the buffer consists of only a null-terminator and return if so (in effect skipping that frame). I tested by running one of the unit tests both before and after my change.
Before:
/data/users/davidlam/llvm/build 19:51$ ASAN_OPTIONS=allow_addr2line=true:external_symbolizer_path=/usr/local/bin/addr2line ASAN_SYMBOLIZER_PATH=../build/bin/llvm-symbolizer ../build/projects/compiler-rt/test/sanitizer_common/asan-x86_64-Linux/Output/symbolize_stack.cc.tmp #0 0x4ffd23 in __sanitizer_print_stack_trace /data/users/davidlam/llvm/llvm/projects/compiler-rt/lib/asan/asan_stack.cc:38 ==1180931==WARNING: Symbolizer buffer too small==1180931==AddressSanitizer CHECK failed: /data/users/davidlam/llvm/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc:282 "((garbage)) != (0)(0x0, 0x0)
After:
/data/users/davidlam/llvm/build 21:04$ ASAN_OPTIONS=allow_addr2line=true:external_symbolizer_path=/usr/local/bin/addr2line ../build/projects/compiler-rt/test/sanitizer_common/asan-x86_64-Linux/Output/symbolize_stack.cc.tmp #0 0x4ffd23 in __sanitizer_print_stack_trace /data/users/davidlam/llvm/llvm/projects/compiler-rt/lib/asan/asan_stack.cc:38 ==2250158==WARNING: Symbolizer buffer too small #1 0x52dc84 (/data/users/davidlam/llvm/build/projects/compiler-rt/test/sanitizer_common/asan-x86_64-Linux/Output/symbolize_stack.cc.tmp+0x52dc84) ==2250158==WARNING: Symbolizer buffer too small #2 0x52d93f (/data/users/davidlam/llvm/build/projects/compiler-rt/test/sanitizer_common/asan-x86_64-Linux/Output/symbolize_stack.cc.tmp+0x52d93f) ==2250158==WARNING: Symbolizer buffer too small #3 0x52d4ff (/data/users/davidlam/llvm/build/projects/compiler-rt/test/sanitizer_common/asan-x86_64-Linux/Output/symbolize_stack.cc.tmp+0x52d4ff) ==2250158==WARNING: Symbolizer buffer too small #4 0x52d0bf (/data/users/davidlam/llvm/build/projects/compiler-rt/test/sanitizer_common/asan-x86_64-Linux/Output/symbolize_stack.cc.tmp+0x52d0bf) #5 0x52cc7f in > >, std::allocator<std::vector<int, std::allocator<int> > > > > >, std::allocator<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > > > > > > > >, std::allocator<std::vector<std::vector<std::vector<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > >, std::allocator<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > > > >, std::allocator<std::vector<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > >, std::allocator<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > > > > > >, std::allocator<std::vector<std::vector<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > >, std::allocator<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > > > >, std::allocator<std::vector<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > >, std::allocator<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > > > > > > > > > >, std::allocator<std::vector<std::vector<std::vector<std::vector<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > >, std::allocator<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > > > >, std::allocator<std::vector<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > >, std::allocator<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > > > > > >, std::allocator<std::vector<std::vector<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > >, std::allocator<std::vector<std:: ==2250158==WARNING: Symbolizer buffer too small #6 0x52c83f (/data/users/davidlam/llvm/build/projects/compiler-rt/test/sanitizer_common/asan-x86_64-Linux/Output/symbolize_stack.cc.tmp+0x52c83f) ==2250158==WARNING: Symbolizer buffer too small #7 0x52c3ff (/data/users/davidlam/llvm/build/projects/compiler-rt/test/sanitizer_common/asan-x86_64-Linux/Output/symbolize_stack.cc.tmp+0x52c3ff) ==2250158==WARNING: Symbolizer buffer too small #8 0x52bfbf (/data/users/davidlam/llvm/build/projects/compiler-rt/test/sanitizer_common/asan-x86_64-Linux/Output/symbolize_stack.cc.tmp+0x52bfbf) ==2250158==WARNING: Symbolizer buffer too small #9 0x52bb7f (/data/users/davidlam/llvm/build/projects/compiler-rt/test/sanitizer_common/asan-x86_64-Linux/Output/symbolize_stack.cc.tmp+0x52bb7f) #10 0x52b72f in t, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > > > >, std::allocator<std::vector<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > >, std::allocator<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > > > > > > > > >(std::vector<std::vector<std::vector<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > >, std::allocator<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > > > >, std::allocator<std::vector<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > >, std::allocator<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > > > > > >, std::allocator<std::vector<std::vector<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > >, std::allocator<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > > > >, std::allocator<std::vector<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > >, std::allocator<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > > > > > > > > const&) /data/users/davidlam/llvm/llvm/projects/compiler-rt/test/sanitizer_common/TestCases/symbolize_stack.cc:16 #11 0x52b4ef in void A<7>::RecursiveTemplateFunction<std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > > >(std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > > const&) /data/users/davidlam/llvm/llvm/projects/compiler-rt/test/sanitizer_common/TestCases/symbolize_stack.cc:16 #12 0x52b372 in void A<10>::RecursiveTemplateFunction<int>(int const&) /data/users/davidlam/llvm/llvm/projects/compiler-rt/test/sanitizer_common/TestCases/symbolize_stack.cc:16 #13 0x7fbf7d47fb34 in __libc_start_main ??:? #14 0x41ad6b in main /data/users/davidlam/llvm/llvm/projects/compiler-rt/test/sanitizer_common/TestCases/symbolize_stack.cc:27