1 // RUN: %clang_hwasan -g %s -o %t
2 // RUN: not %run %t 0 2>&1 | FileCheck %s
3 // RUN: not %run %t -33 2>&1 | FileCheck %s
4 // REQUIRES: pointer-tagging
11 /* Testing longjmp/setjmp should test that accesses to scopes jmp'd over are
13 int __attribute__((noinline
))
14 uses_longjmp(int **other_array
, int num
, jmp_buf env
) {
15 int internal_array
[100] = {0};
16 *other_array
= &internal_array
[0];
20 int __attribute__((noinline
)) uses_setjmp(int num
) {
22 int *other_array
= NULL
;
25 if ((temp
= sigsetjmp(cur_env
, 1)) != 0) {
26 assert((num
== 0 && temp
== 1) || (num
!= 0 && temp
== num
));
27 // We're testing that our longjmp interceptor untagged the previous stack.
28 // Hence the tag in memory should be zero.
29 if (other_array
!= NULL
)
30 return other_array
[0];
31 // CHECK: READ of size 4 at{{.*}}tags: {{..}}/00
34 return uses_longjmp(&other_array
, num
, cur_env
);
37 int __attribute__((noinline
)) main(int argc
, char *argv
[]) {
39 int longjmp_retval
= atoi(argv
[1]);
40 uses_setjmp(longjmp_retval
);