Skip to content

Commit 515c435

Browse files
committed
[asan] Fix stack pointers comparison in FakeStack
Unlucky naming top/bottom for stack bounds, has nothing to do with real stack top. So top > botton is here, and opposite of 9be8892 assumption. This is minimal fix in case cherry-picks is needed. Naming fix and testing (if possible) will be in followup patches. Introduced in 9be8892. Can't symply reverted 9be8892 as it fixes ~10 year old bug, accidentally exposed by a8bef88.
1 parent b7cf9bb commit 515c435

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler-rt/lib/asan/asan_fake_stack.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ NOINLINE void FakeStack::GC(uptr real_stack) {
151151
return; // Try again when we have a thread.
152152
auto top = curr_thread->stack_top();
153153
auto bottom = curr_thread->stack_bottom();
154-
if (real_stack < top || real_stack > bottom)
154+
if (real_stack < bottom || real_stack > top)
155155
return; // Not the default stack.
156156

157157
for (uptr class_id = 0; class_id < kNumberOfSizeClasses; class_id++) {
@@ -162,7 +162,7 @@ NOINLINE void FakeStack::GC(uptr real_stack) {
162162
FakeFrame *ff = reinterpret_cast<FakeFrame *>(
163163
GetFrame(stack_size_log(), class_id, i));
164164
// GC only on the default stack.
165-
if (ff->real_stack < real_stack && ff->real_stack >= top) {
165+
if (bottom < ff->real_stack && ff->real_stack < real_stack) {
166166
flags[i] = 0;
167167
// Poison the frame, so the any access will be reported as UAR.
168168
SetShadow(reinterpret_cast<uptr>(ff), BytesInSizeClass(class_id),

0 commit comments

Comments
 (0)