1 //===-- asan_activation.cc --------------------------------------*- C++ -*-===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // This file is a part of AddressSanitizer, an address sanity checker.
10 // ASan activation/deactivation logic.
11 //===----------------------------------------------------------------------===//
13 #include "asan_activation.h"
14 #include "asan_allocator.h"
15 #include "asan_flags.h"
16 #include "asan_internal.h"
17 #include "sanitizer_common/sanitizer_flags.h"
21 static struct AsanDeactivatedFlags
{
24 int malloc_context_size
;
26 } asan_deactivated_flags
;
28 static bool asan_is_deactivated
;
30 void AsanStartDeactivated() {
31 VReport(1, "Deactivating ASan\n");
33 asan_deactivated_flags
.quarantine_size
= flags()->quarantine_size
;
34 asan_deactivated_flags
.max_redzone
= flags()->max_redzone
;
35 asan_deactivated_flags
.poison_heap
= flags()->poison_heap
;
36 asan_deactivated_flags
.malloc_context_size
=
37 common_flags()->malloc_context_size
;
39 flags()->quarantine_size
= 0;
40 flags()->max_redzone
= 16;
41 flags()->poison_heap
= false;
42 common_flags()->malloc_context_size
= 0;
44 asan_is_deactivated
= true;
48 if (!asan_is_deactivated
) return;
49 VReport(1, "Activating ASan\n");
51 // Restore flag values.
52 // FIXME: this is not atomic, and there may be other threads alive.
53 flags()->quarantine_size
= asan_deactivated_flags
.quarantine_size
;
54 flags()->max_redzone
= asan_deactivated_flags
.max_redzone
;
55 flags()->poison_heap
= asan_deactivated_flags
.poison_heap
;
56 common_flags()->malloc_context_size
=
57 asan_deactivated_flags
.malloc_context_size
;
59 ParseExtraActivationFlags();
61 ReInitializeAllocator();
63 asan_is_deactivated
= false;
66 "quarantine_size %d, max_redzone %d, poison_heap %d, malloc_context_size "
68 flags()->quarantine_size
, flags()->max_redzone
, flags()->poison_heap
,
69 common_flags()->malloc_context_size
);