Visitar URL original
[3.15] gh-158803: Fix crash in bytes.join() on a concurrently mutated list by christianaurichzm · Pull Request #159030 · python/cpython · GitHub
Skip to content

[3.15] gh-158803: Fix crash in bytes.join() on a concurrently mutated list - #159030

Open
christianaurichzm wants to merge 1 commit into
python:3.15from
christianaurichzm:backport-05d80cc-3.15
Open

christianaurichzm wants to merge 1 commit into
python:3.15from
christianaurichzm:backport-05d80cc-3.15

Conversation

@christianaurichzm

@christianaurichzm christianaurichzm commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

In the free-threaded build, bytes.join() and bytearray.join() read
items from the list with borrowed references and without holding its
lock, so another thread could replace and free an item before it was
increfed.

Run the join under Py_BEGIN_CRITICAL_SECTION_SEQUENCE_FAST, as
PyUnicode_Join() already does.
(cherry picked from commit 05d80cc)

The test file and the pycore_critical_section.h include in Objects/bytesobject.c come from gh-128213 on main, which is not in 3.15, so the test file is created here with only the new test and the include is added.

…utated list (pythonGH-158910)

In the free-threaded build, bytes.join() and bytearray.join() read
items from the list with borrowed references and without holding its
lock, so another thread could replace and free an item before it was
increfed.

Run the join under Py_BEGIN_CRITICAL_SECTION_SEQUENCE_FAST, as
PyUnicode_Join() already does.
(cherry picked from commit 05d80cc)
@christianaurichzm christianaurichzm changed the title [3.15] gh-158803: Fix crash in bytes.join() on a concurrently mutated… [3.15] gh-158803: Fix crash in bytes.join() on a concurrently mutated list Oct 8, 2026
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.

1 participant