1 // Build a library with origin tracking and an executable w/o origin tracking.
2 // Test that origin tracking is enabled at runtime.
3 // RUN: %clangxx_lsan -O0 %s -DBUILD_SO -fPIC -shared -o %t-so.so
4 // RUN: %clangxx_lsan -O0 %s -ldl -o %t && not %run %t 2>&1 | FileCheck %s
5 // RUN: %clangxx_lsan -O0 %s -ldl -o %t -DSUPPRESS_LEAK && %run %t
12 void *my_alloc(unsigned sz
) { return malloc(sz
); }
23 extern "C" const char *__lsan_default_suppressions() {
24 return "leak:^<unknown module>$";
28 int main(int argc
, char **argv
) {
30 std::string path
= std::string(argv
[0]) + "-so.so";
34 void *handle
= dlopen(path
.c_str(), RTLD_LAZY
);
36 typedef void *(*fn
)(unsigned sz
);
37 fn my_alloc
= (fn
)dlsym(handle
, "my_alloc");
39 for (int i
= 0; i
< 100; ++i
)