Skip to content

Commit 75a7742

Browse files
committed
Try to avoid unregistered globals when scanning the list
Change-Id: I369acc7d84a4aa8abdeb394070573122c5f07e78
1 parent 3922a59 commit 75a7742

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

compiler-rt/lib/asan/asan_globals.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,28 @@ static u32 FindRegistrationSite(const Global *g) {
109109
return 0;
110110
}
111111

112+
#if SANITIZER_AMDGPU
113+
static bool IsValidGlobal(const Global *g) {
114+
return
115+
*(u8 *)MEM_TO_SHADOW((uptr)g) == kAsanGlobalRedzoneMagic &&
116+
*(u8 *)MEM_TO_SHADOW((uptr)g + sizeof(__asan_global) - sizeof(uptr))
117+
== kAsanGlobalRedzoneMagic &&
118+
g->size < g->size_with_redzone &&
119+
g->has_dynamic_init < 2 &&
120+
g->beg < kHighMemEnd;
121+
}
122+
#endif
123+
112124
int GetGlobalsForAddress(uptr addr, Global *globals, u32 *reg_sites,
113125
int max_globals) {
114126
if (!flags()->report_globals) return 0;
115127
Lock lock(&mu_for_globals);
116128
int res = 0;
117129
for (ListOfGlobals *l = list_of_all_globals; l; l = l->next) {
130+
#if SANITIZER_AMDGPU
131+
if (!IsValidGlobal(l->g))
132+
continue;
133+
#endif
118134
const Global &g = *l->g;
119135
if (flags()->report_globals >= 2)
120136
ReportGlobal(g, "Search");

0 commit comments

Comments
 (0)