From 28ef2068e657eea25a54ab55a76b6ede9bcaddec Mon Sep 17 00:00:00 2001 From: Vasiliy Kiryanov Date: Mon, 21 Sep 2026 19:21:28 -0400 Subject: [PATCH 1/7] gh-136872: Let --with-pymalloc override the sanitizer default --with-address-sanitizer and --with-memory-sanitizer unconditionally disabled pymalloc, even when --with-pymalloc was given explicitly. Only apply the default when the user did not specify a preference. --- .../2026-09-21-19-20-42.gh-issue-136872.a2tSc_.rst | 3 +++ configure | 10 ++++++++-- configure.ac | 10 ++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2026-09-21-19-20-42.gh-issue-136872.a2tSc_.rst diff --git a/Misc/NEWS.d/next/Build/2026-09-21-19-20-42.gh-issue-136872.a2tSc_.rst b/Misc/NEWS.d/next/Build/2026-09-21-19-20-42.gh-issue-136872.a2tSc_.rst new file mode 100644 index 00000000000000..06c5eea63e1c8c --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-09-21-19-20-42.gh-issue-136872.a2tSc_.rst @@ -0,0 +1,3 @@ +The :option:`--with-address-sanitizer` and :option:`--with-memory-sanitizer` +configure options no longer override an explicit :option:`--with-pymalloc`. +pymalloc is still disabled by default in sanitizer builds. diff --git a/configure b/configure index 9af81bf7cc67d1..8ea5ec82c0711b 100755 --- a/configure +++ b/configure @@ -14156,7 +14156,10 @@ printf "%s\n" "$withval" >&6; } BASECFLAGS="-fsanitize=address -fno-omit-frame-pointer $BASECFLAGS" LDFLAGS="-fsanitize=address $LDFLAGS" # ASan works by controlling memory allocation, our own malloc interferes. -with_pymalloc="no" +# Disable pymalloc by default, but allow --with-pymalloc to override. +if test -z "$with_pymalloc"; then + with_pymalloc="no" +fi else case e in #( e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 @@ -14219,7 +14222,10 @@ esac fi # MSan works by controlling memory allocation, our own malloc interferes. -with_pymalloc="no" +# Disable pymalloc by default, but allow --with-pymalloc to override. +if test -z "$with_pymalloc"; then + with_pymalloc="no" +fi else case e in #( e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 diff --git a/configure.ac b/configure.ac index 92d7c17a6b448b..ec267faead8eae 100644 --- a/configure.ac +++ b/configure.ac @@ -3524,7 +3524,10 @@ AC_MSG_RESULT([$withval]) BASECFLAGS="-fsanitize=address -fno-omit-frame-pointer $BASECFLAGS" LDFLAGS="-fsanitize=address $LDFLAGS" # ASan works by controlling memory allocation, our own malloc interferes. -with_pymalloc="no" +# Disable pymalloc by default, but allow --with-pymalloc to override. +if test -z "$with_pymalloc"; then + with_pymalloc="no" +fi ], [AC_MSG_RESULT([no])]) @@ -3542,7 +3545,10 @@ BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame- LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 $LDFLAGS" ],[AC_MSG_ERROR([The selected compiler doesn't support memory sanitizer])]) # MSan works by controlling memory allocation, our own malloc interferes. -with_pymalloc="no" +# Disable pymalloc by default, but allow --with-pymalloc to override. +if test -z "$with_pymalloc"; then + with_pymalloc="no" +fi ], [AC_MSG_RESULT([no])]) From b1700e33efdb4696259432f8e9e8a1ac07a6a83c Mon Sep 17 00:00:00 2001 From: Vasiliy Kiryanov Date: Mon, 21 Sep 2026 20:48:47 -0400 Subject: [PATCH 2/7] Fix NEWS entry option reference --- .../next/Build/2026-09-21-19-20-42.gh-issue-136872.a2tSc_.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Build/2026-09-21-19-20-42.gh-issue-136872.a2tSc_.rst b/Misc/NEWS.d/next/Build/2026-09-21-19-20-42.gh-issue-136872.a2tSc_.rst index 06c5eea63e1c8c..4aaa1e5f36c2ac 100644 --- a/Misc/NEWS.d/next/Build/2026-09-21-19-20-42.gh-issue-136872.a2tSc_.rst +++ b/Misc/NEWS.d/next/Build/2026-09-21-19-20-42.gh-issue-136872.a2tSc_.rst @@ -1,3 +1,3 @@ The :option:`--with-address-sanitizer` and :option:`--with-memory-sanitizer` -configure options no longer override an explicit :option:`--with-pymalloc`. +configure options no longer override an explicit :option:`--with-pymalloc <--without-pymalloc>`. pymalloc is still disabled by default in sanitizer builds. From 00442719b1a18f60dbb58fe35844f8188f727db6 Mon Sep 17 00:00:00 2001 From: Vasiliy Kiryanov Date: Tue, 22 Sep 2026 16:53:34 -0400 Subject: [PATCH 3/7] gh-136872: Clarify sanitizers behavior --- Doc/using/configure.rst | 3 --- configure.ac | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Doc/using/configure.rst b/Doc/using/configure.rst index 88b5f35a796796..279436e03db71b 100644 --- a/Doc/using/configure.rst +++ b/Doc/using/configure.rst @@ -1009,9 +1009,6 @@ Debug options .. option:: --with-address-sanitizer Enable AddressSanitizer memory error detector, ``asan`` (default is no). - To improve ASan detection capabilities you may also want to combine this - with :option:`--without-pymalloc` to disable the specialized small-object - allocator whose allocations are not tracked by ASan. .. versionadded:: 3.6 diff --git a/configure.ac b/configure.ac index ec267faead8eae..fabcced6a72118 100644 --- a/configure.ac +++ b/configure.ac @@ -3523,8 +3523,8 @@ AC_ARG_WITH([address_sanitizer], AC_MSG_RESULT([$withval]) BASECFLAGS="-fsanitize=address -fno-omit-frame-pointer $BASECFLAGS" LDFLAGS="-fsanitize=address $LDFLAGS" -# ASan works by controlling memory allocation, our own malloc interferes. -# Disable pymalloc by default, but allow --with-pymalloc to override. +# ASan works by controlling memory allocation, our own malloc interferes, +# so disable it by default, but allow --with-pymalloc to override. if test -z "$with_pymalloc"; then with_pymalloc="no" fi @@ -3544,8 +3544,8 @@ AX_CHECK_COMPILE_FLAG([-fsanitize=memory],[ BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer $BASECFLAGS" LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 $LDFLAGS" ],[AC_MSG_ERROR([The selected compiler doesn't support memory sanitizer])]) -# MSan works by controlling memory allocation, our own malloc interferes. -# Disable pymalloc by default, but allow --with-pymalloc to override. +# MSan works by controlling memory allocation, our own malloc interferes, +# so disable it by default, but allow --with-pymalloc to override. if test -z "$with_pymalloc"; then with_pymalloc="no" fi From e536084b6fb3282553f830780b988fab2ba43f59 Mon Sep 17 00:00:00 2001 From: Vasiliy Kiryanov Date: Tue, 22 Sep 2026 20:20:56 -0400 Subject: [PATCH 4/7] gh-136872: Regenerate configure --- configure | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 8ea5ec82c0711b..f3f0ed0a09506e 100755 --- a/configure +++ b/configure @@ -14155,8 +14155,8 @@ then : printf "%s\n" "$withval" >&6; } BASECFLAGS="-fsanitize=address -fno-omit-frame-pointer $BASECFLAGS" LDFLAGS="-fsanitize=address $LDFLAGS" -# ASan works by controlling memory allocation, our own malloc interferes. -# Disable pymalloc by default, but allow --with-pymalloc to override. +# ASan works by controlling memory allocation, our own malloc interferes, +# so disable it by default, but allow --with-pymalloc to override. if test -z "$with_pymalloc"; then with_pymalloc="no" fi @@ -14221,8 +14221,8 @@ else case e in #( esac fi -# MSan works by controlling memory allocation, our own malloc interferes. -# Disable pymalloc by default, but allow --with-pymalloc to override. +# MSan works by controlling memory allocation, our own malloc interferes, +# so disable it by default, but allow --with-pymalloc to override. if test -z "$with_pymalloc"; then with_pymalloc="no" fi From e0a51e2673fbdf0b6e8d7a2eb8af85f95db4935a Mon Sep 17 00:00:00 2001 From: Vasiliy Kiryanov Date: Wed, 23 Sep 2026 06:54:07 -0400 Subject: [PATCH 5/7] gh-136872: Document pymalloc default in sanitizer builds --- Doc/c-api/memory.rst | 8 +++++--- Doc/using/configure.rst | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Doc/c-api/memory.rst b/Doc/c-api/memory.rst index 73310670ac371c..1e6443c92aab21 100644 --- a/Doc/c-api/memory.rst +++ b/Doc/c-api/memory.rst @@ -705,9 +705,11 @@ This allocator is disabled if Python is configured with the :option:`--without-pymalloc` option. It can also be disabled at runtime using the :envvar:`PYTHONMALLOC` environment variable (ex: ``PYTHONMALLOC=malloc``). -Typically, it makes sense to disable the pymalloc allocator when building -Python with AddressSanitizer (:option:`--with-address-sanitizer`) which helps -uncover low level bugs within the C code. +The pymalloc allocator is disabled by default when Python is built with +AddressSanitizer (:option:`--with-address-sanitizer`) or MemorySanitizer +(:option:`--with-memory-sanitizer`), since these sanitizers do not track +allocations made by pymalloc. Pass +:option:`--with-pymalloc <--without-pymalloc>` to enable it anyway. Customize pymalloc Arena Allocator ---------------------------------- diff --git a/Doc/using/configure.rst b/Doc/using/configure.rst index 279436e03db71b..c8c64e5e6916ea 100644 --- a/Doc/using/configure.rst +++ b/Doc/using/configure.rst @@ -1009,12 +1009,16 @@ Debug options .. option:: --with-address-sanitizer Enable AddressSanitizer memory error detector, ``asan`` (default is no). + This disables pymalloc by default, use + :option:`--with-pymalloc <--without-pymalloc>` to enable it. .. versionadded:: 3.6 .. option:: --with-memory-sanitizer Enable MemorySanitizer allocation error detector, ``msan`` (default is no). + This disables pymalloc by default, use + :option:`--with-pymalloc <--without-pymalloc>` to enable it. .. versionadded:: 3.6 From b23d2d19886d3d845e778b3c38baf451e147ea82 Mon Sep 17 00:00:00 2001 From: Vasiliy Kiryanov Date: Wed, 23 Sep 2026 16:21:28 -0400 Subject: [PATCH 6/7] gh-136872: Use malloc as the default allocator under ASan and MSan --- Doc/c-api/memory.rst | 6 ++++-- Doc/using/configure.rst | 8 ++++---- Include/internal/pycore_pymem_init.h | 4 ++++ Lib/test/test_cmd_line.py | 14 +++++++++++--- Lib/test/test_sys.py | 4 +++- .../2026-09-21-19-20-42.gh-issue-136872.a2tSc_.rst | 7 ++++--- Objects/obmalloc.c | 6 ++++++ configure | 10 ++-------- configure.ac | 10 ++-------- 9 files changed, 40 insertions(+), 29 deletions(-) diff --git a/Doc/c-api/memory.rst b/Doc/c-api/memory.rst index 1e6443c92aab21..815342faed5b52 100644 --- a/Doc/c-api/memory.rst +++ b/Doc/c-api/memory.rst @@ -437,6 +437,8 @@ Release build ``"pymalloc"`` ``malloc`` Debug build ``"pymalloc_debug"`` ``malloc`` + debug ``pymalloc`` + debug ``pymalloc`` + debug Release build, without pymalloc ``"malloc"`` ``malloc`` ``malloc`` ``malloc`` Debug build, without pymalloc ``"malloc_debug"`` ``malloc`` + debug ``malloc`` + debug ``malloc`` + debug +Release build, with ASan or MSan ``"malloc"`` ``malloc`` ``malloc`` ``malloc`` +Debug build, with ASan or MSan ``"malloc_debug"`` ``malloc`` + debug ``malloc`` + debug ``malloc`` + debug Free-threaded build ``"mimalloc"`` ``mimalloc`` ``mimalloc`` ``mimalloc`` Free-threaded debug build ``"mimalloc_debug"`` ``mimalloc`` + debug ``mimalloc`` + debug ``mimalloc`` + debug =================================== ======================= ==================== ====================== ====================== @@ -708,8 +710,8 @@ the :envvar:`PYTHONMALLOC` environment variable (ex: ``PYTHONMALLOC=malloc``). The pymalloc allocator is disabled by default when Python is built with AddressSanitizer (:option:`--with-address-sanitizer`) or MemorySanitizer (:option:`--with-memory-sanitizer`), since these sanitizers do not track -allocations made by pymalloc. Pass -:option:`--with-pymalloc <--without-pymalloc>` to enable it anyway. +allocations made by pymalloc. Use +:envvar:`PYTHONMALLOC=pymalloc ` to enable it. Customize pymalloc Arena Allocator ---------------------------------- diff --git a/Doc/using/configure.rst b/Doc/using/configure.rst index c8c64e5e6916ea..25e02b98739d3b 100644 --- a/Doc/using/configure.rst +++ b/Doc/using/configure.rst @@ -1009,16 +1009,16 @@ Debug options .. option:: --with-address-sanitizer Enable AddressSanitizer memory error detector, ``asan`` (default is no). - This disables pymalloc by default, use - :option:`--with-pymalloc <--without-pymalloc>` to enable it. + Python uses ``malloc`` instead of :ref:`pymalloc ` by default. + Set :envvar:`PYTHONMALLOC=pymalloc ` to use pymalloc. .. versionadded:: 3.6 .. option:: --with-memory-sanitizer Enable MemorySanitizer allocation error detector, ``msan`` (default is no). - This disables pymalloc by default, use - :option:`--with-pymalloc <--without-pymalloc>` to enable it. + Python uses ``malloc`` instead of :ref:`pymalloc ` by default. + Set :envvar:`PYTHONMALLOC=pymalloc ` to use pymalloc. .. versionadded:: 3.6 diff --git a/Include/internal/pycore_pymem_init.h b/Include/internal/pycore_pymem_init.h index 2a0e0817dcc7f8..f89eb8bfc4964c 100644 --- a/Include/internal/pycore_pymem_init.h +++ b/Include/internal/pycore_pymem_init.h @@ -36,6 +36,10 @@ extern void _PyMem_MiRawFree(void *, void *); extern void* _PyMem_MiRawRealloc(void *, void *, size_t); # undef PYRAW_ALLOC # define PYRAW_ALLOC {NULL, _PyMem_MiRawMalloc, _PyMem_MiRawCalloc, _PyMem_MiRawRealloc, _PyMem_MiRawFree} +#elif defined(_Py_ADDRESS_SANITIZER) || defined(_Py_MEMORY_SANITIZER) +// Keep in sync with the default allocators in Objects/obmalloc.c. +# define PYOBJ_ALLOC PYRAW_ALLOC +# define PYMEM_ALLOC PYOBJ_ALLOC #elif defined(WITH_PYMALLOC) extern void* _PyObject_Malloc(void *, size_t); extern void* _PyObject_Calloc(void *, size_t, size_t); diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index 4c1abb15c0cb14..716a0bbf3af15e 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -830,10 +830,13 @@ def test_xdev(self): code = "import _testinternalcapi; print(_testinternalcapi.pymem_getallocatorsname())" with support.SuppressCrashReport(): out = self.run_xdev("-c", code, check_exitcode=False) - if support.with_pymalloc(): - alloc_name = "pymalloc_debug" - elif support.Py_GIL_DISABLED: + if support.Py_GIL_DISABLED: alloc_name = "mimalloc_debug" + elif support.check_sanitizer(address=True, memory=True): + # ASan and MSan builds default to malloc, even with pymalloc. + alloc_name = "malloc_debug" + elif support.with_pymalloc(): + alloc_name = "pymalloc_debug" else: alloc_name = "malloc_debug" self.assertEqual(out, alloc_name) @@ -912,10 +915,15 @@ def test_pythonmalloc(self): # Test the PYTHONMALLOC environment variable malloc = not support.Py_GIL_DISABLED pymalloc = support.with_pymalloc() + sanitizer = support.check_sanitizer(address=True, memory=True) mimalloc = support.with_mimalloc() if support.Py_GIL_DISABLED: default_name = 'mimalloc_debug' if support.Py_DEBUG else 'mimalloc' default_name_debug = 'mimalloc_debug' + elif sanitizer: + # ASan and MSan builds default to malloc, even with pymalloc. + default_name = 'malloc_debug' if support.Py_DEBUG else 'malloc' + default_name_debug = 'malloc_debug' elif pymalloc: default_name = 'pymalloc_debug' if support.Py_DEBUG else 'pymalloc' default_name_debug = 'pymalloc_debug' diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index da1bd381dd182e..929d43b0898ed8 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -1129,8 +1129,10 @@ def test_debugmallocstats(self): # The sysconfig vars are not available on Windows. if sys.platform != "win32": with_pymalloc = sysconfig.get_config_var("WITH_PYMALLOC") + with_sanitizer = support.check_sanitizer(address=True, memory=True) self.assertIn(b"free PyDictObjects", err) - if with_pymalloc: + # ASan and MSan builds default to malloc, even with pymalloc. + if with_pymalloc and not with_sanitizer: self.assertIn(b'Small block threshold', err) # The function has no parameter diff --git a/Misc/NEWS.d/next/Build/2026-09-21-19-20-42.gh-issue-136872.a2tSc_.rst b/Misc/NEWS.d/next/Build/2026-09-21-19-20-42.gh-issue-136872.a2tSc_.rst index 4aaa1e5f36c2ac..7e51844695d0e4 100644 --- a/Misc/NEWS.d/next/Build/2026-09-21-19-20-42.gh-issue-136872.a2tSc_.rst +++ b/Misc/NEWS.d/next/Build/2026-09-21-19-20-42.gh-issue-136872.a2tSc_.rst @@ -1,3 +1,4 @@ -The :option:`--with-address-sanitizer` and :option:`--with-memory-sanitizer` -configure options no longer override an explicit :option:`--with-pymalloc <--without-pymalloc>`. -pymalloc is still disabled by default in sanitizer builds. +Python built with :option:`--with-address-sanitizer` or +:option:`--with-memory-sanitizer` now includes pymalloc, but uses ``malloc`` +as the default memory allocator. Set +:envvar:`PYTHONMALLOC=pymalloc ` to use pymalloc. diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c index 9a41a422467223..841fb796e1ced1 100644 --- a/Objects/obmalloc.c +++ b/Objects/obmalloc.c @@ -433,6 +433,12 @@ void* _PyObject_Realloc(void *ctx, void *ptr, size_t size); # define PYRAW_ALLOC MIMALLOC_RAWALLOC # define PYMEM_ALLOC MIMALLOC_ALLOC # define PYOBJ_ALLOC MIMALLOC_OBJALLOC +#elif defined(_Py_ADDRESS_SANITIZER) || defined(_Py_MEMORY_SANITIZER) +// ASan and MSan do not track pymalloc blocks, so use malloc by default. +// pymalloc can still be selected at runtime. +# define PYRAW_ALLOC MALLOC_ALLOC +# define PYMEM_ALLOC MALLOC_ALLOC +# define PYOBJ_ALLOC MALLOC_ALLOC #elif defined(WITH_PYMALLOC) # define PYRAW_ALLOC MALLOC_ALLOC # define PYMEM_ALLOC PYMALLOC_ALLOC diff --git a/configure b/configure index f3f0ed0a09506e..adee2b3b3bb69e 100755 --- a/configure +++ b/configure @@ -14156,10 +14156,7 @@ printf "%s\n" "$withval" >&6; } BASECFLAGS="-fsanitize=address -fno-omit-frame-pointer $BASECFLAGS" LDFLAGS="-fsanitize=address $LDFLAGS" # ASan works by controlling memory allocation, our own malloc interferes, -# so disable it by default, but allow --with-pymalloc to override. -if test -z "$with_pymalloc"; then - with_pymalloc="no" -fi +# so pymalloc is still built, but malloc is the default allocator at runtime. else case e in #( e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 @@ -14222,10 +14219,7 @@ esac fi # MSan works by controlling memory allocation, our own malloc interferes, -# so disable it by default, but allow --with-pymalloc to override. -if test -z "$with_pymalloc"; then - with_pymalloc="no" -fi +# so pymalloc is still built, but malloc is the default allocator at runtime. else case e in #( e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 diff --git a/configure.ac b/configure.ac index fabcced6a72118..1bccce9ecbd2e9 100644 --- a/configure.ac +++ b/configure.ac @@ -3524,10 +3524,7 @@ AC_MSG_RESULT([$withval]) BASECFLAGS="-fsanitize=address -fno-omit-frame-pointer $BASECFLAGS" LDFLAGS="-fsanitize=address $LDFLAGS" # ASan works by controlling memory allocation, our own malloc interferes, -# so disable it by default, but allow --with-pymalloc to override. -if test -z "$with_pymalloc"; then - with_pymalloc="no" -fi +# so pymalloc is still built, but malloc is the default allocator at runtime. ], [AC_MSG_RESULT([no])]) @@ -3545,10 +3542,7 @@ BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame- LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 $LDFLAGS" ],[AC_MSG_ERROR([The selected compiler doesn't support memory sanitizer])]) # MSan works by controlling memory allocation, our own malloc interferes, -# so disable it by default, but allow --with-pymalloc to override. -if test -z "$with_pymalloc"; then - with_pymalloc="no" -fi +# so pymalloc is still built, but malloc is the default allocator at runtime. ], [AC_MSG_RESULT([no])]) From e469c49617d38a5bf9c6e1983a8cc1fd426bd216 Mon Sep 17 00:00:00 2001 From: Vasiliy Kiryanov Date: Thu, 24 Sep 2026 09:49:10 -0400 Subject: [PATCH 7/7] Apply batched suggestions from code review gh-136872: Improve code documentation Co-authored-by: Petr Viktorin --- Doc/using/configure.rst | 6 ++++-- configure.ac | 4 ---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Doc/using/configure.rst b/Doc/using/configure.rst index 25e02b98739d3b..93e7de42160bc4 100644 --- a/Doc/using/configure.rst +++ b/Doc/using/configure.rst @@ -1009,7 +1009,8 @@ Debug options .. option:: --with-address-sanitizer Enable AddressSanitizer memory error detector, ``asan`` (default is no). - Python uses ``malloc`` instead of :ref:`pymalloc ` by default. + + When built with ``asan``, Python uses ``malloc`` instead of :ref:`pymalloc ` by default. Set :envvar:`PYTHONMALLOC=pymalloc ` to use pymalloc. .. versionadded:: 3.6 @@ -1017,7 +1018,8 @@ Debug options .. option:: --with-memory-sanitizer Enable MemorySanitizer allocation error detector, ``msan`` (default is no). - Python uses ``malloc`` instead of :ref:`pymalloc ` by default. + + When built with ``msan``, Python uses ``malloc`` instead of :ref:`pymalloc ` by default. Set :envvar:`PYTHONMALLOC=pymalloc ` to use pymalloc. .. versionadded:: 3.6 diff --git a/configure.ac b/configure.ac index 1bccce9ecbd2e9..cbfbf500f9c6e3 100644 --- a/configure.ac +++ b/configure.ac @@ -3523,8 +3523,6 @@ AC_ARG_WITH([address_sanitizer], AC_MSG_RESULT([$withval]) BASECFLAGS="-fsanitize=address -fno-omit-frame-pointer $BASECFLAGS" LDFLAGS="-fsanitize=address $LDFLAGS" -# ASan works by controlling memory allocation, our own malloc interferes, -# so pymalloc is still built, but malloc is the default allocator at runtime. ], [AC_MSG_RESULT([no])]) @@ -3541,8 +3539,6 @@ AX_CHECK_COMPILE_FLAG([-fsanitize=memory],[ BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer $BASECFLAGS" LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 $LDFLAGS" ],[AC_MSG_ERROR([The selected compiler doesn't support memory sanitizer])]) -# MSan works by controlling memory allocation, our own malloc interferes, -# so pymalloc is still built, but malloc is the default allocator at runtime. ], [AC_MSG_RESULT([no])])