File tree Expand file tree Collapse file tree 2 files changed +24
-19
lines changed Expand file tree Collapse file tree 2 files changed +24
-19
lines changed Original file line number Diff line number Diff line change 14
14
#define MI_DEBUG_FREED PYMEM_DEADBYTE
15
15
#define MI_DEBUG_PADDING PYMEM_FORBIDDENBYTE
16
16
17
+ /* ASAN builds don't use MI_DEBUG. ASAN + MI_DEBUG triggers additional
18
+ * checks, which can cause mimalloc to print warnings to stderr. The
19
+ * warnings break some tests.
20
+ *
21
+ * mi_usable_size: pointer might not point to a valid heap region:
22
+ * ...
23
+ * yes, the previous pointer ... was valid after all
24
+ */
25
+ #if defined(__has_feature )
26
+ # if __has_feature (address_sanitizer )
27
+ # define MI_DEBUG 0
28
+ # endif
29
+ #elif defined(__GNUC__ ) && defined(__SANITIZE_ADDRESS__ )
30
+ # define MI_DEBUG 0
31
+ #endif
32
+
33
+ /* Perform additional checks in debug builds, see mimalloc-types.h
34
+ * - enable basic and internal assertion checks with MI_DEBUG 2
35
+ * - check for double free, invalid pointer free
36
+ * - use guard pages to check for buffer overflows
37
+ */
17
38
#ifdef Py_DEBUG
18
- // see mimalloc-types.h
19
- // basic and internal assertion checks
20
- # define MI_DEBUG 2
21
- // check for double free, buffer overflows and invalid pointer free
39
+ # ifndef MI_DEBUG
40
+ # define MI_DEBUG 2
41
+ # endif
22
42
# define MI_SECURE 4
23
43
#elif defined(PY_MIMALLOC_SECURE )
24
44
# define MI_SECURE PY_MIMALLOC_SECURE
Original file line number Diff line number Diff line change @@ -136,18 +136,6 @@ _PyMem_RawFree(void *Py_UNUSED(ctx), void *ptr)
136
136
137
137
#ifdef WITH_MIMALLOC
138
138
139
- static void
140
- _PyMimalloc_Config (void ) {
141
- /* XXX Some options cannot be changed because
142
- PyRuntime_Initialize() -> alloc_for_runtime()
143
- allocates memory, which initializes mimalloc.
144
-
145
- verbose logging breaks some tests in debug mode:
146
- "pointer might not point to a valid heap region"
147
- */
148
- mi_option_disable (mi_option_verbose );
149
- }
150
-
151
139
static void *
152
140
_PyMimalloc_Malloc (void * ctx , size_t size )
153
141
{
@@ -442,9 +430,6 @@ _PyMem_SetupAllocators(PyMemAllocatorName allocator)
442
430
PyMem_SetupDebugHooks ();
443
431
}
444
432
445
- // set global mimalloc flags
446
- _PyMimalloc_Config ();
447
-
448
433
break ;
449
434
}
450
435
#endif
You can’t perform that action at this time.
0 commit comments