Skip to content

gh-160588: Restore the gh-123022 check in the vendored mimalloc - #160589

Merged
hugovk merged 1 commit into
python:mainfrom
devdavidejesus:fix-mimalloc-gh-123022-check
Oct 24, 2026
Merged

hugovk merged 1 commit into
python:mainfrom
devdavidejesus:fix-mimalloc-gh-123022-check

Conversation

@devdavidejesus

@devdavidejesus devdavidejesus commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

The mimalloc 2.5.2 update (gh-159111) dropped the CPython-specific check from gh-123022 in Objects/mimalloc/os.c, which skips _mi_heap_random_next() while the thread's default heap is not initialized. It looks like another downstream change lost in the upgrade, like the ones restored in gh-160207. This restores it as it was before the update.

On 3.14 the missing check makes Py_Initialize() in a background thread crash on free-threaded release builds (test_init_in_background_thread fails). On main the test passes even without the check, because the raw domain already initializes the heap; the change is here so that it can be backported to 3.15 and 3.14. If gh-159718 (mimalloc v3) lands first, this is not needed on main and could go to 3.15 and 3.14 directly.

Tested on macOS with free-threaded release builds: with this change the test passes 20 of 20 times on 3.14 (20 of 20 crashes without it), and test_embed passes on main and 3.14.

No NEWS entry: the regression is not in any release yet (3.14.9 still has the check).

See #160588.

…malloc

The mimalloc 2.5.2 update dropped the check that skips
_mi_heap_random_next() while the thread's default heap is not
initialized.  Without it, Py_Initialize() in a background thread
crashes on free-threaded release builds of 3.14.
@hugovk

hugovk commented Oct 24, 2026

Copy link
Copy Markdown
Member

cc @corona10 @DinoV Does this help #160183 (comment) ?

We may need some security releases soon, so we'll need https://buildbot.python.org/release-status back to green, which may otherwise require a revert of #160183.

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

lgtm

@corona10 corona10 added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes skip news labels Oct 24, 2026
@hugovk
hugovk merged commit 34889af into python:main Oct 24, 2026
65 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @devdavidejesus for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Oct 24, 2026

Copy link
Copy Markdown

GH-160611 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Oct 24, 2026
@bedevere-app

bedevere-app Bot commented Oct 24, 2026

Copy link
Copy Markdown

GH-160612 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Oct 24, 2026
hugovk pushed a commit that referenced this pull request Oct 24, 2026
GH-160589) (#160612)

Co-authored-by: Davi de Jesus <davidejesus.log@proton.me>
hugovk pushed a commit that referenced this pull request Oct 24, 2026
GH-160589) (#160611)

Co-authored-by: Davi de Jesus <davidejesus.log@proton.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants