1 // Test that registers of running threads are included in the root set.
2 // RUN: %clangxx_lsan -pthread %s -o %t
3 // RUN: %env_lsan_opts="report_objects=1:use_stacks=0:use_registers=0" not %run %t 2>&1 | FileCheck %s
4 // RUN: %env_lsan_opts="report_objects=1:use_stacks=0:use_registers=1" %run %t 2>&1
5 // RUN: %env_lsan_opts="" %run %t 2>&1
7 // FIXME: Support more platforms.
8 // REQUIRES: x86-target-arch && linux
10 #include "sanitizer_common/print_address.h"
17 extern "C" void *registers_thread_func(void *arg
) {
18 int *sync
= reinterpret_cast<int *>(arg
);
19 void *p
= malloc(1337);
20 print_address("Test alloc: ", 1, p
);
23 // To store the pointer, choose a register which is unlikely to be reused by
32 #elif defined(__x86_64__)
40 #error "Test is not supported on this architecture."
43 __sync_fetch_and_xor(sync
, 1);
51 int res
= pthread_create(&thread_id
, 0, registers_thread_func
, &sync
);
53 while (!__sync_fetch_and_xor(&sync
, 0))
57 // CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
58 // CHECK: LeakSanitizer: detected memory leaks
59 // CHECK: [[ADDR]] (1337 bytes)
60 // CHECK: SUMMARY: {{.*}}Sanitizer: