Summary: This is needed because on some platforms we can't install signal handlers and so the application just traps (i.e. crashes) rather than being intercepted by ASan's signal handler which in the default Darwin config doesn't exit with a crashing exit code. rdar://problem/57984547 Reviewers: yln, kubamracek, jfb Subscribers: #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D71573
21 lines
497 B
C++
21 lines
497 B
C++
// Make sure the zones created by malloc_create_zone() are write-protected.
|
|
#include <malloc/malloc.h>
|
|
#include <stdio.h>
|
|
|
|
// RUN: %clangxx_asan %s -o %t
|
|
// RUN: ASAN_OPTIONS="abort_on_error=1" not --crash %run %t 2>&1 | FileCheck %s
|
|
|
|
|
|
void *pwn(malloc_zone_t *unused_zone, size_t unused_size) {
|
|
printf("PWNED\n");
|
|
return NULL;
|
|
}
|
|
|
|
int main() {
|
|
malloc_zone_t *zone = malloc_create_zone(0, 0);
|
|
zone->malloc = pwn;
|
|
void *v = malloc_zone_malloc(zone, 1);
|
|
// CHECK-NOT: PWNED
|
|
return 0;
|
|
}
|