Skip to content

Commit

Permalink
[asan_symbolize] Fix broken pipe handling for python 2.7
Browse files Browse the repository at this point in the history
I D65322 I added a check for BrokenPipeError. However, python 2.7 doesn't
have BrokenPipeError. To be python 2.7 and 3 compatible we need to catch
IOError instead and check for errno == errno.EPIPE.

llvm-svn: 370025
  • Loading branch information
arichardson committed Aug 27, 2019
1 parent 09fcec7 commit 677c6dd
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions compiler-rt/lib/asan/scripts/asan_symbolize.py
Expand Up @@ -21,6 +21,7 @@
"""
import argparse
import bisect
import errno
import getopt
import logging
import os
Expand Down Expand Up @@ -202,9 +203,14 @@ def symbolize(self, addr, binary, offset):
logging.debug("got empty function and file name -> unknown function")
function_name = '??'
file_name = '??:0'
lines.append((function_name, file_name));
except BrokenPipeError:
logging.debug("got broken pipe, addr2line returncode=%d" % self.pipe.poll())
lines.append((function_name, file_name))
except IOError as e:
# EPIPE happens if addr2line exits early (which some implementations do
# if an invalid file is passed).
if e.errno == errno.EPIPE:
logging.debug("addr2line exited early (broken pipe), returncode=%d" % self.pipe.poll())
else:
logging.debug("unexpected I/O exception communicating with addr2line", exc_info=e)
lines.append(('??', '??:0'))
except Exception as e:
logging.debug("got unknown exception communicating with addr2line", exc_info=e)
Expand Down

0 comments on commit 677c6dd

Please sign in to comment.