Add extra return value checks into stack-use-after-return.cc to help diagnose AArch64 test failures for <https://reviews.llvm.org/D30267>. NFC.

llvm-svn: 298193
This commit is contained in:
Kuba Mracek 2017-03-18 20:39:31 +00:00
parent 7693b116a1
commit 07183b4a82
1 changed files with 22 additions and 3 deletions

View File

@ -14,8 +14,9 @@
// RUN: %env_asan_opts=detect_stack_use_after_return=1:max_uar_stack_size_log=20:verbosity=1 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-20 %s
// RUN: %env_asan_opts=detect_stack_use_after_return=1:min_uar_stack_size_log=24:max_uar_stack_size_log=24:verbosity=1 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-24 %s
#include <stdio.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef kSize
# define kSize 1
@ -66,8 +67,26 @@ int main(int argc, char **argv) {
#if UseThread
pthread_attr_t attr;
pthread_attr_init(&attr);
if (kStackSize > 0)
pthread_attr_setstacksize(&attr, kStackSize);
if (kStackSize > 0) {
int ret = pthread_attr_setstacksize(&attr, kStackSize);
if (ret != 0) {
fprintf(stderr, "pthread_attr_setstacksize returned %d\n", ret);
abort();
}
size_t stacksize_check;
ret = pthread_attr_getstacksize(&attr, &stacksize_check);
if (ret != 0) {
fprintf(stderr, "pthread_attr_getstacksize returned %d\n", ret);
abort();
}
if (stacksize_check != kStackSize) {
fprintf(stderr, "Unable to set stack size to %d, the stack size is %d.\n",
kStackSize, stacksize_check);
abort();
}
}
pthread_t t;
pthread_create(&t, &attr, Thread, 0);
pthread_attr_destroy(&attr);