Skip to content

Commit 2ef2f46

Browse files
committed
scripts/addr2line.py: fix hanging with the new llvm-addr2line version
addr2line.py invokes "addr2line" tool in a "server" mode where addresses are fed via stdin. It intentionally makes a corresponding "addr2line" tool generate a known "invalid address" pattern at the end of each address decoding by feeding it a "0x0" address in order to denote the end of it because a single address can be decoded into multiple lines due to inlining. The above strategy assumes that 0x0 address is always going to be interpreted as an invalid one by both add2line and by llvm-addr2line. However, at least llvm-addr2line 18.1.3 doesn't always interpret it this way. On the other hand an empty line does always generate an expected (invalid address) output. On top of that it looks like a new llvm-addr2line changed the "invalid address" pattern format. This patch adds a new "invalid input" pattern to a dummy_pattern and changes the way we generate such an output by pushing line that only has a ',' charachter instead of a 0x0 address. Ref scylladb#2609
1 parent ff24926 commit 2ef2f46

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

scripts/addr2line.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ class Addr2Line:
5454
dummy_pattern = re.compile(
5555
r"(.*0x0000000000000000: \?\? \?\?:0\n)" # addr2line pattern
5656
r"|"
57-
r"(.*0x0: \?\? at .*\n)" # llvm-addr2line pattern
57+
r"(.*0x0: \?\? at .*\n)" # llvm-addr2line patterns
58+
r"|"
59+
r"(\?\? at \?\?:0\n)"
60+
r"|"
61+
r"(,\n)"
5862
)
5963

6064
def __init__(
@@ -97,7 +101,7 @@ def __init__(
97101
# will just exit. We need to be robust against that. We
98102
# can't just wait on self._addr2line since there is no
99103
# guarantee on what timeout is sufficient.
100-
self._input.write('\n')
104+
self._input.write(',\n')
101105
self._input.flush()
102106
res = self._output.readline()
103107
self._missing = res == ''
@@ -129,9 +133,9 @@ def _read_resolved_address(self):
129133
def __call__(self, address: str):
130134
if self._missing:
131135
return " ".join([self._binary, address, '\n'])
132-
# We print a dummy 0x0 address after the address we are interested in
136+
# We trigger a dummy "invalid" address printout after the address we are interested in
133137
# which we can look for in _read_address
134-
inputline = address + '\n0x0\n'
138+
inputline = address + '\n,\n'
135139
self._parent.debug('Add2Line sending input to stdin:', inputline)
136140
self._input.write(inputline)
137141
self._input.flush()

0 commit comments

Comments
 (0)