]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/lsan/TestCases/large_allocation_leak.cc
Vendor import of compiler-rt trunk r300890:
[FreeBSD/FreeBSD.git] / test / lsan / TestCases / large_allocation_leak.cc
1 // Test that LargeMmapAllocator's chunks aren't reachable via some internal data structure.
2 // RUN: LSAN_BASE="report_objects=1:use_stacks=0:use_registers=0"
3 // RUN: %clangxx_lsan %s -o %t
4 // RUN: %env_lsan_opts=$LSAN_BASE not %run %t 2>&1 | FileCheck %s
5
6 // For 32 bit LSan it's pretty likely that large chunks are "reachable" from some
7 // internal data structures (e.g. Glibc global data).
8 // UNSUPPORTED: x86, arm
9
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include "sanitizer_common/print_address.h"
13
14 int main() {
15   // maxsize in primary allocator is always less than this (1 << 25).
16   void *large_alloc = malloc(33554432);
17   print_address("Test alloc: ", 1, large_alloc);
18   return 0;
19 }
20 // CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
21 // CHECK: LeakSanitizer: detected memory leaks
22 // CHECK: [[ADDR]] (33554432 bytes)
23 // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: