The configure script doesn't allow running ASan with PyMalloc
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug report
Bug description:
The --with-address-sanitizer configure option overrides whatever pymalloc option one provides which it should not.
We should either allow it to work with --with-pymalloc, or, delete the line that disables pymalloc. I discussed it a bit during EP2025 sprint with @encukou .
This is done due to the line here:
https://github.com/python/cpython/blame/4a151cae3317ce133bdf0792fb1064c5030e588c/configure#L13352
I believe that CPython works fine with ASan + PyMalloc. I have tested it by removing the line above. Then the import _testcapi; _testcapi.WITH_PYMALLOC is True and there doesn't seem to be ASan crashes. However, there are leaks being detected, even when building Python, so I did all this with export ASAN_OPTIONS=detect_leaks=0.
It is also worth noting that we:
- List the
--without-pymallocflag in the devguide when showing how to run ASan. - We mention there, that the flag is not necessary, but it makes ASan more effective.
- We mention in CPython docs that it makes sense to disable PyMalloc when running ASan here
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting the configure script around line 13352 and the related --with-address-sanitizer and --with-pymalloc handling. Build CPython with both options, check _testcapi.WITH_PYMALLOC, and verify the resulting ASan behavior while accounting for the documented detect_leaks setting and the linked devguide and memory documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, shell
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100