]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-123022: Fix crash with `Py_Initialize` in background thread (#123052)
authorSam Gross <colesbury@gmail.com>
Sat, 17 Aug 2024 20:04:08 +0000 (16:04 -0400)
committerGitHub <noreply@github.com>
Sat, 17 Aug 2024 20:04:08 +0000 (16:04 -0400)
commitd061ffea7b408861d0a9d311e92c363da284971d
tree669ad7db230f0d6e3004a36bab12f817f23a25b6
parent40632b1f1da573f6d5e12453007474bcf70fba22
gh-123022: Fix crash with  `Py_Initialize` in background thread (#123052)

Check that the current default heap is initialized in
`_mi_os_get_aligned_hint` and `mi_os_claim_huge_pages`.

The mimalloc function `_mi_os_get_aligned_hint` assumes that there is an
initialized default heap. This is true for our main thread, but not for
background threads. The problematic code path is usually called during
initialization (i.e., `Py_Initialize`), but it may also be called if the
program allocates large amounts of memory in total.

The crash only affected the free-threaded build.
Lib/test/test_embed.py
Misc/NEWS.d/next/Core_and_Builtins/2024-08-15-19-28-43.gh-issue-123022.m3EF9E.rst [new file with mode: 0644]
Objects/mimalloc/os.c
Programs/_testembed.c