Skip to content

Commit ad2be02

Browse files
committed
ASAN: Support detect_invalid_pointer_pairs=1 with detect_stack_use_after_return=1
Do not crash when AsanThread::GetStackVariableShadowStart does not find a variable for a pointer on a shadow stack. Differential Revision: https://reviews.llvm.org/D89552
1 parent f2a0687 commit ad2be02

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

compiler-rt/lib/asan/asan_thread.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,9 @@ uptr AsanThread::GetStackVariableShadowStart(uptr addr) {
366366
bottom = stack_bottom();
367367
} else if (has_fake_stack()) {
368368
bottom = fake_stack()->AddrIsInFakeStack(addr);
369-
CHECK(bottom);
369+
if (bottom == 0) {
370+
return 0;
371+
}
370372
} else {
371373
return 0;
372374
}

compiler-rt/test/asan/TestCases/invalid-pointer-pairs-subtract-success.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %clangxx_asan -O0 %s -o %t -mllvm -asan-detect-invalid-pointer-pair
22

33
// RUN: %env_asan_opts=detect_invalid_pointer_pairs=2 %run %t
4+
// RUN: %env_asan_opts=detect_invalid_pointer_pairs=2,detect_stack_use_after_return=1 %run %t
45

56
#include <assert.h>
67
#include <stdlib.h>

0 commit comments

Comments
 (0)