Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0367c82

Browse files
committed
Really force off MI_DEBUG in release builds
1 parent f27d04f commit 0367c82

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

Include/internal/pycore_mimalloc.h

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
#define MI_DEBUG_FREED PYMEM_DEADBYTE
1515
#define MI_DEBUG_PADDING PYMEM_FORBIDDENBYTE
1616

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.
17+
/* ASAN builds don't use MI_DEBUG.
18+
*
19+
* ASAN + MI_DEBUG triggers additional checks, which can cause mimalloc
20+
* to print warnings to stderr. The warnings break some tests.
2021
*
2122
* mi_usable_size: pointer might not point to a valid heap region:
2223
* ...
@@ -30,18 +31,26 @@
3031
# define MI_DEBUG 0
3132
#endif
3233

33-
/* Perform additional checks in debug builds, see mimalloc-types.h
34+
#ifdef Py_DEBUG
35+
/* Debug: Perform additional checks in debug builds, see mimalloc-types.h
3436
* - enable basic and internal assertion checks with MI_DEBUG 2
3537
* - check for double free, invalid pointer free
3638
* - use guard pages to check for buffer overflows
3739
*/
38-
#ifdef Py_DEBUG
3940
# ifndef MI_DEBUG
4041
# define MI_DEBUG 2
4142
# endif
4243
# define MI_SECURE 4
43-
#elif defined(PY_MIMALLOC_SECURE)
44-
# define MI_SECURE PY_MIMALLOC_SECURE
44+
#else
45+
// Production: no debug checks, secure depends on --enable-mimalloc-secure
46+
# ifndef MI_DEBUG
47+
# define MI_DEBUG 0
48+
# endif
49+
# if defined(PY_MIMALLOC_SECURE)
50+
# define MI_SECURE PY_MIMALLOC_SECURE
51+
# else
52+
# define MI_SECURE 0
53+
# endif
4554
#endif
4655

4756
/* Prefix all non-static symbols with "_Py_"

0 commit comments

Comments
 (0)