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