diff options
author | Serge Guelton <sguelton@redhat.com> | 2019-07-20 17:44:30 +0000 |
---|---|---|
committer | Serge Guelton <sguelton@redhat.com> | 2019-07-20 17:44:30 +0000 |
commit | 8de9918a1cdb0072162f3cda17ad6bd1caacac78 (patch) | |
tree | dcce4b7baebf12cad188a18ed63dd803ed9b1519 /test | |
parent | 7c291538704b53863b81df2ec7c1fef553d5a80b (diff) | |
download | compiler-rt-8de9918a1cdb0072162f3cda17ad6bd1caacac78.tar.gz |
Fix asan infinite loop on undefined symbol
Fix llvm#39641
Recommit of r366413
Differential Revision: https://reviews.llvm.org/D63877
llvm-svn: 366632
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@366638 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/asan/TestCases/Linux/dlopen-mixed-c-cxx.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/asan/TestCases/Linux/dlopen-mixed-c-cxx.c b/test/asan/TestCases/Linux/dlopen-mixed-c-cxx.c new file mode 100644 index 000000000..bad22fe2c --- /dev/null +++ b/test/asan/TestCases/Linux/dlopen-mixed-c-cxx.c @@ -0,0 +1,43 @@ +// RUN: %clangxx_asan -xc++ -shared -fPIC -o %t.so - < %s +// RUN: %clang_asan %s -o %t.out -ldl +// +// RUN: { env ASAN_OPTIONS=verbosity=1 %t.out %t.so || : ; } 2>&1 | FileCheck %s +// +// CHECK: {{.*}}AddressSanitizer: failed to intercept '__cxa_{{.*}}throw{{.*}}' +// +// REQUIRES: x86_64-target-arch && !android + +#ifdef __cplusplus + +static void foo(void) { + int i = 0; + throw(i); +} + +extern "C" { +int bar(void); +}; +int bar(void) { + try { + foo(); + } catch (int i) { + return i; + } + return -1; +} + +#else + +#include <assert.h> +#include <dlfcn.h> + +int main(int argc, char **argv) { + int (*bar)(void); + void *handle = dlopen(argv[1], RTLD_LAZY); + assert(handle); + bar = dlsym(handle, "bar"); + assert(bar); + return bar(); +} + +#endif |