Skip to content

[3.15] gh-159538: Fix deep chain leak in test_deeply_dotted_name (GH-159576) - #159609

Merged
vstinner merged 1 commit into
python:3.15from
miss-islington:backport-c84d4b5-3.15
Oct 17, 2026
Merged

vstinner merged 1 commit into
python:3.15from
miss-islington:backport-c84d4b5-3.15

Conversation

@miss-islington

@miss-islington miss-islington commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

test_deeply_dotted_name() builds a 10,000-deep chain of lazy import
placeholders in a thread with a 256 KiB C stack. Freeing the chain
there defers most deallocations to the trashcan, which only drains them
once the stack margin recovers. With a stack that small the margin
never does, so the deferred objects were leaked when the thread exited,
which -R reports as a reference leak on platforms with larger frames
such as PPC64LE.

Clear the namespace in a cleanup, which runs on the main thread.
(cherry picked from commit c84d4b5)

Co-authored-by: Brittany Reynoso breynoso@meta.com

…onGH-159576)

test_deeply_dotted_name() builds a 10,000-deep chain of lazy import
placeholders in a thread with a 256 KiB C stack.  Freeing the chain
there defers most deallocations to the trashcan, which only drains them
once the stack margin recovers.  With a stack that small the margin
never does, so the deferred objects were leaked when the thread exited,
which -R reports as a reference leak on platforms with larger frames
such as PPC64LE.

Clear the namespace in a cleanup, which runs on the main thread.
(cherry picked from commit c84d4b5)

Co-authored-by: Brittany Reynoso <breynoso@meta.com>
@vstinner
vstinner enabled auto-merge (squash) October 17, 2026 01:46
@vstinner
vstinner merged commit 491ccaf into python:3.15 Oct 17, 2026
55 checks passed
@miss-islington
miss-islington deleted the backport-c84d4b5-3.15 branch October 17, 2026 02:16
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