2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00

Fix entity renumbering in util/parse_tsan.py

util/parse_tsan.py builds tables of mutexes, threads, and pointers it
finds in the TSAN report provided to it as a command-line argument and
then replaces all mentions of each of these entities so that they are
numbered sequentially in the processed report.  For example, this line:

    Cycle in lock order graph: M0 (...) => M5 (...) => M9 (...) => M0

is expected to become:

    Cycle in lock order graph: M1 (...) => M2 (...) => M3 (...) => M1

Problems arise when the gaps between mutex/thread identifiers present on
a single line are smaller than the total number of mutexes/threads found
by the script so far.  For example, the following line:

    Cycle in lock order graph: M0 (...) => M1 (...) => M2 (...) => M0

first gets turned into:

    Cycle in lock order graph: M1 (...) => M1 (...) => M2 (...) => M1

and then into:

    Cycle in lock order graph: M2 (...) => M2 (...) => M2 (...) => M2

In other words, lines like this become garbled due to information loss.

The problem stems from the fact that the numbering scheme the script
uses for identifying mutexes and threads is exactly the same as the one
used by TSAN itself.  Update util/parse_tsan.py so that it uses
zero-padded numbers instead, making the "overlapping" demonstrated above
impossible.
This commit is contained in:
Michał Kępień
2023-06-15 16:17:14 +02:00
parent f22046d61b
commit 7f0790c82f

View File

@@ -110,13 +110,13 @@ with open(sys.argv[1], "r", encoding="utf-8") as f:
S.p_index += 1
for k, v in S.mutexes.items():
r = re.compile(k)
line = r.sub("M%s" % v, line)
line = r.sub("M{:04d}".format(v), line)
for k, v in S.threads.items():
r = re.compile(k)
line = r.sub("T%s" % v, line)
line = r.sub("T{:04d}".format(v), line)
for k, v in S.pointers.items():
r = re.compile(k)
line = r.sub("0x%s" % str(v).zfill(12), line)
line = r.sub("0x{:012d}".format(v), line)
line = STACK.sub("", line)
line = PID.sub("", line)