cpython/Doc/c-api
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
..
abstract.rst gh-85275: Remove old buffer APIs (#105137) 2023-06-02 01:12:40 +00:00
allocation.rst gh-134160: Use multi-phase init in documentation examples (#134296) 2025-05-26 21:43:35 +00:00
apiabiversion.rst gh-128629: Add Py_PACK_VERSION and Py_PACK_FULL_VERSION (GH-128630) 2025-01-09 11:10:28 +01:00
arg.rst gh-132629: Deprecate accepting out-of-range values for unsigned integers in PyArg_Parse (GH-132630) 2025-07-13 12:44:54 +03:00
bool.rst gh-110481, doc: Add "immortal" term to the glossary (#112180) 2023-11-17 15:09:19 +01:00
buffer.rst gh-132246: Add PEP 688 to C Buffer Protocol docs (#132249) 2025-04-08 10:43:27 -07:00
bytearray.rst Python 3.14.0a5 2025-02-11 19:16:29 +02:00
bytes.rst gh-121645: Fix typo in PyBytes_Join() doc (#123783) 2024-09-06 16:08:17 +02:00
call.rst Add a version added note for PY_VECTORCALL_ARGUMENTS_OFFSET (#110963) 2023-10-23 19:00:52 +03:00
capsule.rst gh-76595: Add note on PyCapsule_Import behavior (GH-134022) 2025-06-28 09:01:41 -04:00
cell.rst gh-121533: Improve PyCell_[Get,Set] docs: mention the exceptions (#121534) 2024-07-09 18:47:35 +03:00
code.rst gh-135755: Document __future__.* and CO_* as proper Sphinx objects (GH-135980) 2025-07-07 12:31:13 +02:00
codec.rst gh-107298: Fix doc references to undocumented modules (#107300) 2023-07-26 18:59:06 +02:00
complex.rst gh-128813: hide mixed-mode functions for complex arithmetic from C-API (#131703) 2025-04-22 14:18:18 +02:00
concrete.rst GH-97950: Use new-style index directive ('object') (#104158) 2023-05-04 13:04:41 +03:00
contextvars.rst gh-124872: Replace enter/exit events with "switched" (#125532) 2024-10-16 13:53:21 +02:00
conversion.rst gh-120026: soft deprecate Py_HUGE_VAL macro (#120027) 2024-11-01 22:04:31 +00:00
coro.rst bpo-42528: Improve the docs of most Py*_Check{,Exact} API calls (GH-23602) 2021-01-06 12:38:26 +01:00
datetime.rst gh-123517: Remove unnecessary `:meth:` parentheses (#123518) 2024-09-01 05:59:42 +01:00
descriptor.rst bpo-40170: Convert PyDescr_IsData() to static inline function (GH-24535) 2021-02-16 08:50:00 +01:00
dict.rst gh-127989: C API: Refer to "attached thread states" instead of the GIL (GH-127990) 2025-03-20 13:06:59 +01:00
exceptions.rst gh-136209: Add .. c:var:: declarations for C exception types (GH-136210) 2025-07-10 13:07:55 +02:00
extension-modules.rst Docs: Remove unnecessary trailing backslashes (GH-135781) 2025-06-21 09:01:14 -04:00
file.rst gh-115172: Fix explicit index extries for the C API (GH-115173) 2024-02-11 12:23:30 +02:00
float.rst gh-136663: fix signatures of PyFloat_Pack/Unpack in docs (#136664) 2025-07-15 11:00:12 +05:30
frame.rst gh-118915: C API: Document frame locals proxies. (#127720) 2024-12-11 17:28:44 +01:00
function.rst gh-135755: Docs: C API: Document missing PyFunction_GET* macros (GH-135762) 2025-06-25 08:44:55 +00:00
gcsupport.rst gh-75459: Doc: C API: Improve object life cycle documentation (GH-125962) 2025-05-20 14:25:50 +02:00
gen.rst bpo-42528: Improve the docs of most Py*_Check{,Exact} API calls (GH-23602) 2021-01-06 12:38:26 +01:00
hash.rst gh-122854: Add Py_HashBuffer() function (#122855) 2024-08-30 15:42:27 +00:00
import.rst gh-133644: remove deprecated PyImport_ImportModuleNoBlock (#133655) 2025-05-08 13:08:43 +00:00
index.rst gh-134160: Split extension module init from PyModule docs; emphasize multi-phase init (GH-135126) 2025-06-13 16:39:35 +02:00
init.rst gh-134009: Expose PyMutex_IsLocked in the public C API (gh-134365) 2025-07-01 13:26:13 -04:00
init_config.rst GH-133711: Enable UTF-8 mode by default (PEP 686) (#133712) 2025-07-15 10:45:41 +01:00
intro.rst gh-134160: Split extension module init from PyModule docs; emphasize multi-phase init (GH-135126) 2025-06-13 16:39:35 +02:00
iter.rst gh-105201: Add PyIter_NextItem() (#122331) 2024-08-08 00:47:15 +02:00
iterator.rst gh-107298: Fix Sphinx warnings in the C API doc (#107302) 2023-07-27 01:41:15 +02:00
lifecycle.dot gh-75459: Doc: C API: Improve object life cycle documentation (GH-125962) 2025-05-20 14:25:50 +02:00
lifecycle.dot.css gh-75459: Doc: C API: Improve object life cycle documentation (GH-125962) 2025-05-20 14:25:50 +02:00
lifecycle.dot.pdf gh-75459: Doc: C API: Improve object life cycle documentation (GH-125962) 2025-05-20 14:25:50 +02:00
lifecycle.dot.svg gh-75459: Doc: C API: Improve object life cycle documentation (GH-125962) 2025-05-20 14:25:50 +02:00
lifecycle.rst Remove newline in Doc/c-api/lifecycle.rst for gettext builder (GH-135013) 2025-06-02 21:13:08 +03:00
list.rst gh-121403: Add notes for PyList_GetXXX APIs about the need for init (gh-121626) 2024-07-16 10:16:41 +09:00
long.rst Docs: Fix duplicate word typos (GH-135958) 2025-06-26 20:00:19 -04:00
mapping.rst gh-108511: Add C API functions which do not silently ignore errors (GH-109025) 2023-09-17 14:23:31 +03:00
marshal.rst gh-125063: marshal: Add version 5, improve documentation (GH-126829) 2024-11-15 13:48:57 +01:00
memory.rst Doc/c-api/memory.rst: extend --without-pymalloc doc with ASan information (GH-136790) 2025-07-19 13:52:54 +02:00
memoryview.rst gh-101100: Fix sphinx warnings in Doc/c-api/memoryview.rst (GH-114669) 2024-01-29 11:56:11 +02:00
method.rst gh-107091: Fix the use of some C domain roles (#107092) 2023-07-23 12:27:05 +02:00
module.rst gh-134160: Split extension module init from PyModule docs; emphasize multi-phase init (GH-135126) 2025-06-13 16:39:35 +02:00
monitoring.rst Python 3.14.0a7 2025-04-08 14:20:51 +03:00
none.rst gh-110481, doc: Add "immortal" term to the glossary (#112180) 2023-11-17 15:09:19 +01:00
number.rst gh-121905: Consistently use "floating-point" instead of "floating point" (GH-121907) 2024-07-19 08:06:02 +00:00
object.rst Docs: Fix and improve the PyUnstable_Object_EnableDeferredRefcount documentation (GH-135323) 2025-07-13 02:46:13 -04:00
objimpl.rst gh-75459: Doc: C API: Improve object life cycle documentation (GH-125962) 2025-05-20 14:25:50 +02:00
perfmaps.rst gh-127989: C API: Refer to "attached thread states" instead of the GIL (GH-127990) 2025-03-20 13:06:59 +01:00
refcounting.rst Docs: Fix markups for emphasis (GH-135598) 2025-06-18 13:32:43 -04:00
reflection.rst gh-127989: C API: Refer to "attached thread states" instead of the GIL (GH-127990) 2025-03-20 13:06:59 +01:00
sequence.rst gh-127896: Add missing documentation of PySequence_In (GH-127979) 2024-12-16 14:56:04 +01:00
set.rst gh-101100: Fix Sphinx reference warnings (GH-112416) 2023-11-25 15:40:19 -08:00
slice.rst gh-130214: Document PyEllipsis_Type (GH-130215) 2025-02-17 13:56:33 +01:00
stable.rst gh-134830: Fix reference in Doc/extending/windows.rst (GH-134831) 2025-06-03 00:08:20 +02:00
structures.rst gh-135913: Document ob_refcnt, ob_type, ob_size (GH-135914) 2025-07-07 14:05:17 +02:00
sys.rst gh-108512: Add and use new replacements for PySys_GetObject() (GH-111035) 2025-05-28 20:11:09 +03:00
time.rst gh-127989: C API: Refer to "attached thread states" instead of the GIL (GH-127990) 2025-03-20 13:06:59 +01:00
tuple.rst gh-124182: Explain naming rules for struct sequence types (#124335) 2024-10-07 19:52:34 +02:00
type.rst Document that PyType_GetModuleByDef returns a borrowed reference (GH-135666) 2025-06-19 09:00:41 +02:00
typehints.rst gh-107298: Fix Sphinx warnings in the C API doc (#107302) 2023-07-27 01:41:15 +02:00
typeobj.rst gh-135913: Document ob_refcnt, ob_type, ob_size (GH-135914) 2025-07-07 14:05:17 +02:00
unicode.rst gh-133968: Update PyUnicodeWriter_WriteASCII() documentation (#135297) 2025-06-09 14:47:02 +02:00
utilities.rst gh-110850: Add PyTime_t C API (GH-115215) 2024-02-12 18:13:10 +01:00
veryhigh.rst gh-135755: Document __future__.* and CO_* as proper Sphinx objects (GH-135980) 2025-07-07 12:31:13 +02:00
weakref.rst gh-128008: Add PyWeakref_IsDead() (GH-128009) 2024-12-19 16:17:15 +01:00