Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit f23db13

Browse files
committed
[asan_symbolize] Fix broken pipe handling for python 2.7
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@370025 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 0e6b6a3 commit f23db13

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/asan/scripts/asan_symbolize.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"""
2222
import argparse
2323
import bisect
24+
import errno
2425
import getopt
2526
import logging
2627
import os
@@ -202,9 +203,14 @@ def symbolize(self, addr, binary, offset):
202203
logging.debug("got empty function and file name -> unknown function")
203204
function_name = '??'
204205
file_name = '??:0'
205-
lines.append((function_name, file_name));
206-
except BrokenPipeError:
207-
logging.debug("got broken pipe, addr2line returncode=%d" % self.pipe.poll())
206+
lines.append((function_name, file_name))
207+
except IOError as e:
208+
# EPIPE happens if addr2line exits early (which some implementations do
209+
# if an invalid file is passed).
210+
if e.errno == errno.EPIPE:
211+
logging.debug("addr2line exited early (broken pipe), returncode=%d" % self.pipe.poll())
212+
else:
213+
logging.debug("unexpected I/O exception communicating with addr2line", exc_info=e)
208214
lines.append(('??', '??:0'))
209215
except Exception as e:
210216
logging.debug("got unknown exception communicating with addr2line", exc_info=e)

0 commit comments

Comments
 (0)