cpython/Doc/using
Disconnect3d d19bb44713
Doc/c-api/memory.rst: extend --without-pymalloc doc with ASan information (GH-136790)
* Doc/c-api/memory.rst: extend --without-pymalloc doc with ASan information

This commit extends the documentation for disabling pymalloc with the `--without-pymalloc` flag regarding why it is worth to use it when enabling AddressSanitizer for Python build (which is done, e.g., in CPython's CI builds).

I have tested the CPython latest main build with both ASan and pymalloc enabled and it seems to work just fine. I did run the `python -m test` suite which didn't uncover any ASan crashes (though, it detected some memory leaks, which I believe are irrelevant here).

I have discussed ASan and this flag with @encukou on the CPython Core sprint on EuroPython 2025. We initially thought that the `--without-pymalloc` flag is needed for ASan builds 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:
acefb978dc/Objects/obmalloc.c (L2096-L2110)

While the annotation macro is defined here:
acefb978dc/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

* Update Doc/c-api/memory.rst

* Improve --with-address-sanitizer and pymalloc docs

---------

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-07-19 13:52:54 +02:00
..
android.rst gh-131531: android.py enhancements to support cibuildwheel (#132870) 2025-06-05 13:46:16 +08:00
cmdline.rst Docs: Fix duplicate word typos (GH-135958) 2025-06-26 20:00:19 -04:00
configure.rst Doc/c-api/memory.rst: extend --without-pymalloc doc with ASan information (GH-136790) 2025-07-19 13:52:54 +02:00
editors.rst gh-59149: Setup documentation for IDLE on Linux and add section in Editors (#130003) 2025-02-12 03:16:56 -05:00
index.rst
ios.rst gh-135966: Modify iOS testbed to make app_packages a site directory (#135967) 2025-06-27 12:46:49 +08:00
mac.rst gh-119132: Update 'Using Python on macOS' documentation. (#135591) 2025-06-16 19:35:59 -04:00
mac_installer_01_introduction.png
mac_installer_02_readme.png
mac_installer_03_license.png
mac_installer_04_installation_type.png
mac_installer_05_custom_install.png
mac_installer_06_summary.png
mac_installer_07_applications.png
mac_installer_08_install_certificates.png
mac_installer_09_custom_install_free_threaded.png
unix.rst Docs: fix shell command formatting (#131310) 2025-03-19 09:42:47 +02:00
win_install_freethreaded.png
win_installer.png
windows.rst GH-133711: Enable UTF-8 mode by default (PEP 686) (#133712) 2025-07-15 10:45:41 +01:00