1 // This test is broken with shared libstdc++ / libc++ on Android.
2 // RUN: %clangxx_hwasan -static-libstdc++ %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=GOOD
3 // RUN: %clangxx_hwasan -static-libstdc++ -DNO_SANITIZE_F %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=GOOD
4 // RUN: %clangxx_hwasan_oldrt -static-libstdc++ %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=GOOD
5 // RUN: %clangxx_hwasan_oldrt -static-libstdc++ %s -mllvm -hwasan-instrument-landing-pads=0 -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=BAD
7 // C++ tests on x86_64 require instrumented libc++/libstdc++.
8 // REQUIRES: aarch64-target-arch
13 static void optimization_barrier(void* arg
) {
14 asm volatile("" : : "r"(arg
) : "memory");
17 __attribute__((noinline
))
20 optimization_barrier(x
);
21 throw std::runtime_error("hello");
24 __attribute__((noinline
))
27 optimization_barrier(x
);
29 optimization_barrier(x
);
32 __attribute__((noinline
))
33 void hwasan_read(char *p
, int size
) {
35 for (int i
= 0; i
< size
; ++i
)
39 __attribute__((noinline
, no_sanitize("hwaddress"))) void after_catch() {
41 hwasan_read(&x
[0], sizeof(x
));
45 __attribute__((noinline
))
47 __attribute__((no_sanitize("hwaddress")))
52 // Put two tagged frames on the stack, throw an exception from the deepest one.
54 } catch (const std::runtime_error
&e
) {
55 // Put an untagged frame on stack, check that it is indeed untagged.
56 // This relies on exception support zeroing out stack tags.
59 // Check that an in-scope stack allocation is still tagged.
60 // This relies on exception support not zeroing too much.
61 hwasan_read(&x
[0], sizeof(x
));
63 printf("%s\n", e
.what());