This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] Handle None value when polling addr2line pipe
ClosedPublic

Authored by DavidSpickett on May 5 2021, 3:57 AM.

Details

Summary

According to:
https://docs.python.org/3/library/subprocess.html#subprocess.Popen.poll

poll can return None if the process hasn't terminated.

I'm not quite sure how addr2line could end up closing the pipe without
terminating but we did see this happen on one of our bots:

<...>scripts/asan_symbolize.py",
line 211, in symbolize
    logging.debug("addr2line exited early (broken pipe), returncode=%d"
% self.pipe.poll())
TypeError: %d format: a number is required, not NoneType

Handle None by printing a message that we couldn't get the return
code.

Diff Detail

Event Timeline

DavidSpickett created this revision.May 5 2021, 3:57 AM
DavidSpickett requested review of this revision.May 5 2021, 3:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 5 2021, 3:57 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript

See https://lab.llvm.org/buildbot/#/builders/7/builds/2652

I presume this is a niche case, perhaps addr2line closes the pipe and is in the process of exiting by the time we poll(). If it had been later then it would work fine.
(and it looks like a transient error since there were no related changes in this build)

delcypher requested changes to this revision.May 6 2021, 10:47 AM
delcypher added inline comments.
compiler-rt/lib/asan/scripts/asan_symbolize.py
214

You don't need to do string interpolation here. You can just do

logging.debug("returncode=%d", self.pipe.poll())

even better yet

logging.debug("returncode={}".format(self.pipe.poll()))

which shouldn't care if self.pipe.poll() is not an integer.

I'm not sure if we've adopted python3 in this file yet but if we have then we could also do

logging.debug(f'returncode={self.pipe.poll()}')
This revision now requires changes to proceed.May 6 2021, 10:47 AM

Use f-string to format.

https://llvm.org/docs/GettingStarted.html#software requires
Python >=3.6 for the test suite and I can always fall back
to .format if bots break.

DavidSpickett marked an inline comment as done.May 7 2021, 1:55 AM
This revision is now accepted and ready to land.May 8 2021, 3:18 PM
This revision was landed with ongoing or failed builds.May 10 2021, 1:46 AM
This revision was automatically updated to reflect the committed changes.