1 // Test shadow faults during esan initialization as well as
2 // faults during dlsym's calloc during interceptor init.
4 // RUN: %clang_esan_wset %s -o %t
5 // RUN: %run %t 2>&1 | FileCheck %s
6 // Stucks at init and no clone feature equivalent.
7 // UNSUPPORTED: freebsd
13 // Our goal is to emulate an instrumented allocator, whose calloc
14 // invoked from dlsym will trigger shadow faults, to test an
15 // early shadow fault during esan interceptor init.
16 // We do this by replacing calloc:
17 void *calloc(size_t size, size_t n) {
18 // Unfortunately we can't print anything to make the test
19 // ensure we got here b/c the sanitizer interceptors can't
20 // handle that during interceptor init.
22 // Ensure we trigger a shadow write fault:
25 // Now just emulate calloc.
26 void *res = malloc(size*n);
27 memset(res, 0, size*n);
31 int main(int argc, char **argv) {