| 1 |
// RUN: %clangxx -O1 %s -o %t && %run %t |
| 2 |
// REQUIRES: page-size-4096 |
| 3 |
// UNSUPPORTED: android |
| 4 |
|
| 5 |
// Fail on powerpc64 bots with: |
| 6 |
// AddressSanitizer: CHECK failed: asan_thread.cpp:315 "((AddrIsInStack((uptr)&local))) != (0)" |
| 7 |
// https://lab.llvm.org/buildbot/#/builders/18/builds/8162 |
| 8 |
// UNSUPPORTED: target=powerpc64{{.*}} |
| 9 |
/// Occasionally fail on loongarch64 machine |
| 10 |
// UNSUPPORTED: target=loongarch64{{.*}} |
| 11 |
|
| 12 |
#include <assert.h> |
| 13 |
#include <stdlib.h> |
| 14 |
#include <sys/resource.h> |
| 15 |
#include <sys/wait.h> |
| 16 |
#include <unistd.h> |
| 17 |
|
| 18 |
int main(int argc, char **argv) { |
| 19 |
if (getenv("SANITIZER_TEST_REEXECED")) |
| 20 |
exit(0); |
| 21 |
struct rlimit rl; |
| 22 |
assert(!getrlimit(RLIMIT_STACK, &rl)); |
| 23 |
struct rlimit rl_new = rl; |
| 24 |
rl_new.rlim_cur = 17351; |
| 25 |
assert(!setrlimit(RLIMIT_STACK, &rl_new)); |
| 26 |
int pid = fork(); |
| 27 |
assert(pid >= 0); |
| 28 |
if (pid == 0) { |
| 29 |
const char *envp[] = {"SANITIZER_TEST_REEXECED=1", nullptr}; |
| 30 |
execve(argv[0], argv, const_cast<char **>(envp)); |
| 31 |
assert(false); |
| 32 |
} |
| 33 |
int status; |
| 34 |
while (waitpid(-1, &status, __WALL) != pid) { |
| 35 |
} |
| 36 |
assert(WIFEXITED(status) && WEXITSTATUS(status) == 0); |
| 37 |
return 0; |
| 38 |
} |