diff options
Diffstat (limited to 'compiler-rt/lib/msan/tests/msan_test.cpp')
| -rw-r--r-- | compiler-rt/lib/msan/tests/msan_test.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/compiler-rt/lib/msan/tests/msan_test.cpp b/compiler-rt/lib/msan/tests/msan_test.cpp index c1cae3dad1f..2d67b6ff645 100644 --- a/compiler-rt/lib/msan/tests/msan_test.cpp +++ b/compiler-rt/lib/msan/tests/msan_test.cpp @@ -4798,3 +4798,32 @@ TEST(MemorySanitizer, Bmi) { } } #endif // defined(__x86_64__) + +namespace { +volatile long z; + +__attribute__((noinline,optnone)) void f(long a, long b, long c, long d, long e, long f) { + z = a + b + c + d + e + f; +} + +__attribute__((noinline,optnone)) void throw_stuff() { + throw 5; +} + +TEST(MemorySanitizer, throw_catch) { + long x; + // Poison __msan_param_tls. + __msan_poison(&x, sizeof(x)); + f(x, x, x, x, x, x); + try { + // This calls __gxx_personality_v0 through some libgcc_s function. + // __gxx_personality_v0 is instrumented, libgcc_s is not; as a result, + // __msan_param_tls is not updated and __gxx_personality_v0 can find + // leftover poison from the previous call. + // A suppression in msan_blacklist.txt makes it work. + throw_stuff(); + } catch (const int &e) { + // pass + } +} +} // namespace |

