Skip to content

Commit ebd4dc4

Browse files
authored
[asan,test] Make alloca_loop_unpoisoning.cpp robust and fix s390x failure (#78774)
In the test from https://reviews.llvm.org/D7098, `char array[len];` is 32-byte aligned on most targets whether it is instrumented or not (optimized by StackSafetyAnalysis), due to the the used `*FrameLowering` being `StackRealignable`. However, when using `SystemZELFFrameLowering`, an un-instrumented `char array[len];` is only 8-byte aligned. Ensure `char array[len];` gets instrumented like what we did to `alloca_vla_interact.cpp`, to make the test pass on s390x.
1 parent ee6199c commit ebd4dc4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

compiler-rt/test/asan/TestCases/alloca_loop_unpoisoning.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// RUN: %env_asan_opts=detect_stack_use_after_return=0 %run %t 2>&1
33
//
44
// REQUIRES: stable-runtime
5-
// UNSUPPORTED: target=s390{{.*}}
65

76
// This testcase checks that allocas and VLAs inside loop are correctly unpoisoned.
87

@@ -25,11 +24,15 @@ void *top, *bot;
2524
__attribute__((noinline)) void foo(int len) {
2625
char x;
2726
top = &x;
28-
char array[len];
27+
volatile char array[len];
28+
if (len)
29+
array[0] = 0;
2930
assert(!(reinterpret_cast<uintptr_t>(array) & 31L));
3031
alloca(len);
3132
for (int i = 0; i < 32; ++i) {
32-
char array[i];
33+
volatile char array[i];
34+
if (i)
35+
array[0] = 0;
3336
bot = alloca(i);
3437
assert(!(reinterpret_cast<uintptr_t>(bot) & 31L));
3538
}

0 commit comments

Comments
 (0)