1 // Test that malloc_zone_from_ptr returns a valid zone for a 0-sized allocation.
3 // RUN: %clang_tsan %s -o %t -framework Foundation
4 // RUN: %run %t 2>&1 | FileCheck %s
6 #include <malloc/malloc.h>
13 void describe_zone(void *p) {
14 malloc_zone_t *z = malloc_zone_from_ptr(p);
16 fprintf(stderr, "zone = %p\n", z);
18 fprintf(stderr, "zone = no zone\n");
28 fprintf(stderr, "size = 0x%zx\n", s);
31 // CHECK: zone = 0x{{[0-9a-f]+}}
35 fprintf(stderr, "size = 0x%zx\n", s);
38 // CHECK: zone = 0x{{[0-9a-f]+}}
42 fprintf(stderr, "size = 0x%zx\n", s);
45 // CHECK: zone = no zone
47 p = mmap(0, 0x1000, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0);
49 fprintf(stderr, "mmap failed\n");
53 fprintf(stderr, "size = 0x%zx\n", s);
56 // CHECK: zone = no zone