FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-136872: Let `--with-pymalloc` override the sanitizer default by vasiliyk · Pull Request #157934 · python/cpython · GitHub

Repository navigation

gh-136872: Let --with-pymalloc override the sanitizer default - #157934

Merged
encukou merged 12 commits into
python:mainfrom
vasiliyk:136872-pymalloc
Oct 7, 2026
Merged

encukou merged 12 commits into
python:mainfrom
vasiliyk:136872-pymalloc

Conversation

vasiliyk commented Sep 21, 2026 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

The --with-address-sanitizer and --with-memory-sanitizer configure options unconditionally set with_pymalloc=no, so an explicit --with-pymalloc was silently ignored.

Only apply that default when --with-pymalloc or --without-pymalloc was not given.
Tested with the regenerated configure:
--with-address-sanitizer --with-pymalloc now defines WITH_PYMALLOC, and
--with-address-sanitizer alone still leaves it undefined.

--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.

StanFromIreland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please also update the --with-address-sanitizer documentation, the note about --without-pymalloc is redundant.

Comment thread configure.ac Outdated
Comment thread configure.ac Outdated
StanFromIreland added a commit to StanFromIreland/cpython that referenced this pull request Sep 22, 2026

read-the-docs-community Bot commented Sep 22, 2026 •
edited
Loading

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34992612 | 📁 Comparing bfe6179 against main (6757482)

  🔍 Preview build  

45 files changed · + 1 added · ± 44 modified

+ Added

± Modified

StanFromIreland changed the title gh-136872: Let --with-pymalloc override the sanitizer default gh-136872: Let --with-pymalloc override the sanitizer default Sep 23, 2026

StanFromIreland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Just a few more docs tweaks, we also need to update the note in the Memory Management documentation:

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.

Comment thread Doc/using/configure.rst
Comment thread Doc/using/configure.rst

encukou commented Sep 23, 2026

Copy link
Copy Markdown
Member

Thanks. This looks like all the places that need changing. I'd be happy to merge as is.

But, looking at the code more closely, I found a potential further improvement: ASAN/MSAN would not be involved in the decision to build with pymalloc, but instead under ASAN/MSAN we'd set the default allocators to malloc. You could then switch at runtime with PYTHONMALLOC=pymalloc.

AFAIK, this would involve an #elif defined(_Py_ADDRESS_SANITIZER) || defined(_Py_MEMORY_SANITIZER) block in obmalloc.c (plus docs/devguide changes).

Do you want to try that?

Copy link
Copy Markdown
Contributor Author

Thanks for the review and the suggestion.
Yes, I'd like to try that.

Copy link
Copy Markdown
Contributor Author

pymalloc is now built under sanitizers, but malloc is the default, and PYTHONMALLOC=pymalloc switches to pymalloc at runtime.

Tests, docs and NEWS are updated.

encukou added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 24, 2026

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @encukou for commit b23d2d1 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F157934%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 24, 2026

encukou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This looks nice, thank you! A few small docs nitpicks:

Comment thread Doc/using/configure.rst Outdated
Comment thread Doc/using/configure.rst Outdated
Comment thread configure.ac Outdated
Comment thread configure.ac Outdated
vasiliyk and others added 2 commits September 24, 2026 09:49
pythongh-136872: Improve code documentation

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Comment thread Doc/using/configure.rst

encukou commented Oct 7, 2026

Copy link
Copy Markdown
Member

I'll do the merge; I hope you don't mind me pushing to the PR directly.

encukou commented Oct 7, 2026

Copy link
Copy Markdown
Member

!buildbot san

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @encukou for commit bfe6179 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F157934%2Fmerge

The command will test the builders whose names match following regular expression: san

The builders matched are:

  • AMD64 Arch Linux Asan PR
  • AMD64 Arch Linux Usan Function PR
  • AMD64 Arch Linux Asan Debug PR
  • x86-64 MacOS Intel ASAN NoGIL PR
  • AMD64 Arch Linux Usan PR

encukou merged commit 2791c35 into python:main Oct 7, 2026
108 of 109 checks passed

encukou commented Oct 7, 2026

Copy link
Copy Markdown
Member

Thank you for the fix!

vasiliyk deleted the 136872-pymalloc branch October 7, 2026 16:20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL