]>
git.proxmox.com Git - rustc.git/blob - src/libcompiler_builtins/compiler-rt/test/lsan/TestCases/use_registers.cc
1 // Test that registers of running threads are included in the root set.
2 // RUN: LSAN_BASE="report_objects=1:use_stacks=0"
3 // RUN: %clangxx_lsan -pthread %s -o %t
4 // RUN: LSAN_OPTIONS=$LSAN_BASE:"use_registers=0" not %run %t 2>&1 | FileCheck %s
5 // RUN: LSAN_OPTIONS=$LSAN_BASE:"use_registers=1" %run %t 2>&1
6 // RUN: LSAN_OPTIONS="" %run %t 2>&1
13 #include "sanitizer_common/print_address.h"
16 void *registers_thread_func(void *arg
) {
17 int *sync
= reinterpret_cast<int *>(arg
);
18 void *p
= malloc(1337);
19 // To store the pointer, choose a register which is unlikely to be reused by
26 #elif defined(__x86_64__)
31 #elif defined(__mips__)
37 #error "Test is not supported on this architecture."
39 print_address("Test alloc: ", 1, p
);
41 __sync_fetch_and_xor(sync
, 1);
49 int res
= pthread_create(&thread_id
, 0, registers_thread_func
, &sync
);
51 while (!__sync_fetch_and_xor(&sync
, 0))
55 // CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
56 // CHECK: LeakSanitizer: detected memory leaks
57 // CHECK: [[ADDR]] (1337 bytes)
58 // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: