1// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2
3#include <stdio.h>
4#include <stdlib.h>
5#include <setjmp.h>
6
7int foo(sigjmp_buf env) {
8 printf(format: "env=%p\n", env);
9 siglongjmp(env: env, val: 42);
10}
11
12int main() {
13 sigjmp_buf env;
14 printf(format: "env=%p\n", env);
15 if (sigsetjmp(env, 1) == 42) {
16 fprintf(stderr, format: "JUMPED\n");
17 return 0;
18 }
19 foo(env);
20 fprintf(stderr, format: "FAILED\n");
21 return 0;
22}
23
24// CHECK-NOT: FAILED
25// CHECK: JUMPED
26

source code of compiler-rt/test/tsan/longjmp2.cpp