Skip to content

Commit 9d6684b

Browse files
author
Stefan Bossbaly
committed
fixup! [HWASan] Fix symbol indexing
1 parent 063e9d3 commit 9d6684b

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

compiler-rt/lib/hwasan/scripts/hwasan_symbolize

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ from __future__ import unicode_literals
1616

1717
import argparse
1818
import glob
19+
import hashlib
1920
import html
2021
import json
2122
import mmap
@@ -312,9 +313,24 @@ class Symbolizer:
312313
except Exception as e:
313314
print("Failed to parse {}: {}".format(filename, e), file=sys.stderr)
314315
continue
315-
if bid is not None:
316-
if bid in self.__index:
317-
print("Duplicate build ID {} for {} and {}".format(bid, self.__index[bid], filename), file=sys.stderr)
316+
if bid is None:
317+
continue
318+
319+
if bid in self.__index:
320+
index_filename = self.__index[bid]
321+
322+
if os.path.samefile(index_filename, filename):
323+
continue
324+
325+
with open(filename, "rb") as f:
326+
file_hash = hashlib.file_digest(f, "sha256")
327+
328+
with open(index_filename, "rb") as f:
329+
index_file_hash = hashlib.file_digest(f, "sha256")
330+
331+
if index_file_hash.digest() != file_hash.digest():
332+
print("Build ID collision! Files share the same BuildId ({}) but their contents differ. Files {} and {} ".format(bid, filename, index_filename), file=sys.stderr)
333+
else:
318334
self.__index[bid] = filename
319335

320336
def symbolize_line(self, line):

0 commit comments

Comments
 (0)