Home | History | Annotate | Download | only in TestCases
      1 // RUN: %clangxx_asan -O %s -o %t && %run %t
      2 
      3 #include <assert.h>
      4 #include <setjmp.h>
      5 #include <stdio.h>
      6 #include <sanitizer/asan_interface.h>
      7 
      8 static jmp_buf buf;
      9 
     10 int 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   // FIXME: Invert this assertion once we fix
     21   // https://code.google.com/p/address-sanitizer/issues/detail?id=258
     22   // This assertion works only w/o UAR.
     23   if (!__asan_get_current_fake_stack())
     24     assert(!__asan_address_is_poisoned(x + 32));
     25 }
     26