Skip to content

Commit 96905b4

Browse files
Update ASan information regarding --without-pymalloc flag (GH-1609)
* Update ASan information regarding --without-pymalloc flag As discussed with @encukou on the CPython Core sprint on EuroPython 2025. We initially thought that the `--without-pymalloc` flag is needed due to the fact pymalloc must hit the begining of page when determining if the memory to be freed comes from pymalloc or was allocated by the system malloc. In other words, we thought, that ASan would crash CPython during free of big objects (allocated by system malloc). It may be that this was the case in the past, but it is not the case anymore as the `address_in_range` function used by pymalloc is annotated to be skipped from the ASan instrumentation. This code can be seen here: https://github.com/python/cpython/blob/acefb978dcb5dd554e3c49a3015ee5c2ad6bfda1/Objects/obmalloc.c#L2096-L2110 While the annotation macro is defined here: https://github.com/python/cpython/blob/acefb978dcb5dd554e3c49a3015ee5c2ad6bfda1/Include/pyport.h#L582-L598 And the corresponding attribute is documented in: * for gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005fsanitize_005faddress-function-attribute * for clang: https://clang.llvm.org/docs/AttributeReference.html#no-sanitize-address-no-address-safety-analysis * Apply suggestions from code review * Apply suggestions from code review --------- Co-authored-by: Petr Viktorin <[email protected]>
1 parent bdfc99f commit 96905b4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

development-tools/clang.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ Then, run ``./configure`` with the relevant flags:
103103
* ASan: ``--with-address-sanitizer --without-pymalloc``
104104
* UBsan: ``--with-undefined-behavior-sanitizer``
105105

106+
The ``--without-pymalloc`` option is not necessary (tests should pass without it),
107+
but disabling pymalloc helps ASan uncover more bugs (ASan does not track
108+
individual allocations done by pymalloc).
109+
106110
It is OK to specify both sanitizers.
107111

108112
After that, run ``make`` and ``make test`` as usual.

0 commit comments

Comments
 (0)