[compiler-rt] r369924 - [asan_symbolize] Avoid blocking when llvm-symbolizer is installed as addr2line

Erik Pilkington via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 28 11:28:27 PDT 2019


Hi Alexander, it looks like this is still failing on Darwin:

http://lab.llvm.org:8080/green/job/clang-stage1-RA/1447/consoleFull#15588960978254eaf0-7326-4999-85b0-388101f2d404

On Tue, Aug 27, 2019 at 1:55 PM Alexander Richardson <
arichardson.kde at gmail.com> wrote:

> Hi Erik,
>
> Looks like DarwinSymbolizer always prints the path even for invalid
> files and I accidentally made the existing test stricter. I will push
> a fix now.
>
> Sorry about the breakage,
> Alex
>
>
> On Tue, 27 Aug 2019 at 20:45, Erik Pilkington <erik.pilkington at gmail.com>
> wrote:
> >
> > Hi Alexander,
> >
> > It looks like this commit is causing failures on Darwin:
> http://lab.llvm.org:8080/green/job/clang-stage1-RA/1421/consoleFull#15588960978254eaf0-7326-4999-85b0-388101f2d404
> >
> > Can you please fix this?
> >
> > Thanks,
> > Erik
> >
> > On Aug 26, 2019, at 9:22 AM, Alexander Richardson via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
> >
> > Author: arichardson
> > Date: Mon Aug 26 09:22:04 2019
> > New Revision: 369924
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=369924&view=rev
> > Log:
> > [asan_symbolize] Avoid blocking when llvm-symbolizer is installed as
> addr2line
> >
> > 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.
> >
> > Reviewers: kcc, eugenis, glider, samsonov
> >
> > Reviewed By: eugenis
> >
> > Subscribers: kubamracek, #sanitizers, llvm-commits
> >
> > Tags: #sanitizers, #llvm
> >
> > Differential Revision: https://reviews.llvm.org/D65322
> >
> > Modified:
> >    compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py
> >
> compiler-rt/trunk/test/asan/TestCases/Posix/asan-symbolize-bad-path.cpp
> >
> > Modified: compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py
> > URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py?rev=369924&r1=369923&r2=369924&view=diff
> >
> ==============================================================================
> > --- compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py (original)
> > +++ compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py Mon Aug 26
> 09:22:04 2019
> > @@ -27,6 +27,7 @@ import os
> > import re
> > import subprocess
> > import sys
> > +from distutils.spawn import find_executable
> >
> > symbolizers = {}
> > demangle = False
> > @@ -153,6 +154,7 @@ class Addr2LineSymbolizer(Symbolizer):
> >     addr2line_tool = 'addr2line'
> >     if binutils_prefix:
> >       addr2line_tool = binutils_prefix + addr2line_tool
> > +    logging.debug('addr2line binary is %s' %
> find_executable(addr2line_tool))
> >     cmd = [addr2line_tool, '-fi']
> >     if demangle:
> >       cmd += ['--demangle']
> > @@ -174,14 +176,34 @@ class Addr2LineSymbolizer(Symbolizer):
> >       is_first_frame = True
> >       while True:
> >         function_name = self.pipe.stdout.readline().rstrip()
> > +        logging.debug("read function_name='%s' from addr2line" %
> function_name)
> > +        # If llvm-symbolizer is installed as addr2line, older versions
> of
> > +        # 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).
> > +        if function_name == '-1':
> > +          logging.debug("got function '-1' -> no more input")
> > +          break
> >         file_name = self.pipe.stdout.readline().rstrip()
> > +        logging.debug("read file_name='%s' from addr2line" % file_name)
> >         if is_first_frame:
> >           is_first_frame = False
> > -        elif function_name in ['', '??']:
> > -          assert file_name == function_name
> > +        elif function_name == '??':
> > +          assert file_name == '??:0', file_name
> > +          logging.debug("got function '??' -> no more input")
> > +          break
> > +        elif not function_name:
> > +          assert not file_name, file_name
> > +          logging.debug("got empty function name -> no more input")
> >           break
> >         lines.append((function_name, file_name));
> > -    except Exception:
> > +    except BrokenPipeError:
> > +      logging.debug("got broken pipe, addr2line returncode=%d" %
> self.pipe.poll())
> > +      lines.append(('??', '??:0'))
> > +    except Exception as e:
> > +      logging.debug("got unknown exception communicating with
> addr2line", exc_info=e)
> >       lines.append(('??', '??:0'))
> >     return ['%s in %s %s' % (addr, function, fix_filename(file)) for
> (function, file) in lines]
> >
> >
> > Modified:
> compiler-rt/trunk/test/asan/TestCases/Posix/asan-symbolize-bad-path.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/asan-symbolize-bad-path.cpp?rev=369924&r1=369923&r2=369924&view=diff
> >
> ==============================================================================
> > ---
> compiler-rt/trunk/test/asan/TestCases/Posix/asan-symbolize-bad-path.cpp
> (original)
> > +++
> compiler-rt/trunk/test/asan/TestCases/Posix/asan-symbolize-bad-path.cpp Mon
> Aug 26 09:22:04 2019
> > @@ -1,4 +1,15 @@
> > // Test that asan_symbolize does not hang when provided with an
> non-existing
> > // path.
> > -// RUN: echo '#0 0xabcdabcd (%t/bad/path+0x1234)' | %asan_symbolize |
> FileCheck %s
> > -// CHECK: #0 0xabcdabcd
> > +// RUN: echo '#0 0xabcdabcd (%t/bad/path+0x1234)' | %asan_symbolize |
> FileCheck %s -check-prefix CHECK-BAD-FILE
> > +// CHECK-BAD-FILE: #0 0xabcdabcd in ?? ??:0
> > +// CHECK-BAD-FILE-EMPTY:
> > +
> > +// Also test that asan_symbolize doesn't assert on an invalid address
> with a valid file:
> > +// RUN: %clangxx_asan -O0 %s -o %t
> > +// RUN: echo '#0 0xabcdabcd (%t+0x0)' | %asan_symbolize | FileCheck %s
> -check-prefix CHECK-BAD-ADDR
> > +// CHECK-BAD-ADDR: #0 0xabcdabcd in ??
> > +// CHECK-BAD-ADDR-EMPTY:
> > +
> > +int main() {
> > +  return 0;
> > +}
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190828/379e7385/attachment.html>


More information about the llvm-commits mailing list