[asan] make heavy_uar_test even heavier

llvm-svn: 179306
This commit is contained in:
Kostya Serebryany 2013-04-11 18:27:02 +00:00
parent 2341ae3856
commit bb68f2cd65
1 changed files with 13 additions and 5 deletions

View File

@ -22,22 +22,30 @@ char *LeakStack() {
return pretend_to_do_something(x);
}
template<size_t kFrameSize>
__attribute__((noinline))
void RecuriveFunctionWithStackFrame(int depth) {
if (depth <= 0) return;
char x[1024];
char x[kFrameSize];
x[0] = depth;
pretend_to_do_something(x);
RecuriveFunctionWithStackFrame(depth - 1);
RecuriveFunctionWithStackFrame<kFrameSize>(depth - 1);
}
int main(int argc, char **argv) {
int n_iter = argc >= 2 ? atoi(argv[1]) : 1000;
int depth = argc >= 3 ? atoi(argv[2]) : 500;
for (int i = 0; i < n_iter; i++)
RecuriveFunctionWithStackFrame(depth);
for (int i = 0; i < n_iter; i++) {
RecuriveFunctionWithStackFrame<10>(depth);
RecuriveFunctionWithStackFrame<100>(depth);
RecuriveFunctionWithStackFrame<500>(depth);
RecuriveFunctionWithStackFrame<1024>(depth);
RecuriveFunctionWithStackFrame<2000>(depth);
RecuriveFunctionWithStackFrame<5000>(depth);
RecuriveFunctionWithStackFrame<10000>(depth);
}
char *stale_stack = LeakStack();
RecuriveFunctionWithStackFrame(10);
RecuriveFunctionWithStackFrame<1024>(10);
stale_stack[100]++;
// CHECK: ERROR: AddressSanitizer: stack-use-after-return on address
// CHECK: is located in stack of thread T0 at offset 132 in frame