Skip to content

Commit c371ee9

Browse files
authored
[Profile][Windows] Fix flakyness when checking existence of binary id (#84196)
There is a small chance that binary id starting with 0 (1/256). It is not sufficient to just check the first byte.
1 parent 3589cac commit c371ee9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

compiler-rt/lib/profile/InstrProfilingPlatformWindows.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ ValueProfNode *EndVNode = &VNodesEnd;
9696
/* lld-link provides __buildid symbol which ponits to the 16 bytes build id when
9797
* using /build-id flag. https://lld.llvm.org/windows_support.html#lld-flags */
9898
#define BUILD_ID_LEN 16
99-
COMPILER_RT_WEAK uint8_t __buildid[BUILD_ID_LEN];
99+
COMPILER_RT_WEAK uint8_t __buildid[BUILD_ID_LEN] = {0};
100100
COMPILER_RT_VISIBILITY int __llvm_write_binary_ids(ProfDataWriter *Writer) {
101-
if (*__buildid) {
101+
static const uint8_t zeros[BUILD_ID_LEN] = {0};
102+
if (memcmp(__buildid, zeros, BUILD_ID_LEN) != 0) {
102103
if (Writer &&
103104
lprofWriteOneBinaryId(Writer, BUILD_ID_LEN, __buildid, 0) == -1)
104105
return -1;

0 commit comments

Comments
 (0)