22 lines · cpp
1// RUN: %clangxx_asan -fsanitize-address-use-after-return=never -O %s -o %t && %run %t2 3#include <assert.h>4#include <setjmp.h>5#include <stdio.h>6#include <sanitizer/asan_interface.h>7 8static jmp_buf buf;9 10int main() {11 char x[32];12 fprintf(stderr, "\nTestLongJmp\n");13 fprintf(stderr, "Before: %p poisoned: %d\n", &x,14 __asan_address_is_poisoned(x + 32));15 assert(__asan_address_is_poisoned(x + 32));16 if (0 == setjmp(buf))17 longjmp(buf, 1);18 fprintf(stderr, "After: %p poisoned: %d\n", &x,19 __asan_address_is_poisoned(x + 32));20 assert(!__asan_address_is_poisoned(x + 32));21}22