GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-141786: Fix missing parent executor during JIT trace by caje731 · Pull Request #142344 · python/cpython

Conversation

@caje731

@caje731 caje731 commented Dec 6, 2025

Copy link
Copy Markdown
Contributor

An executor's trace can point to another executor, forming a graph of traces / executors. Sometimes it is possible while recording a trace that the parent executor is freed / invalidated halfway. This leads to the bug described in the issue gh-141786, which if left unfixed could cause a memory leak.

This patch checks for the validity of the parent executor as well as allowing JIT from the cold executor. While the cold executor is not linked, it is the executor responsible for creating side traces and we still want to JIT from it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@caje731
pythongh-141786 Fix missing parent executor during trace
63662b9
An executor's trace can point to another executor, forming a graph
of traces / executors. Sometimes it is possible while recording a
trace that the parent executor is freed / invalidated halfway. This
leads to the bug described in the issue pythongh-141786, which if left
unfixed could cause a memory leak.

This patch checks for the validity of the parent executor as well
as allowing JIT from the cold executor. While the cold executor is
not linked, it is the executor responsible for creating side traces
and we still want to JIT from it.
@caje731
caje731 requested a review from markshannon as a code owner December 6, 2025 13:37
@bedevere-app bedevere-app Bot added the awaiting review label Dec 6, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Dec 6, 2025
JIT: assertion failure in pycore_backoff.h #141786
Closed
@caje731

caje731 commented Dec 6, 2025

Copy link
Copy Markdown
Contributor Author

@Fidget-Spinner who the issue is currently assigned to has helped me with this PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fidget-Spinner

Fidget-Spinner commented Dec 6, 2025

Copy link
Copy Markdown
Member

@devdanzin can we use your repro as a test case please?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@devdanzin

devdanzin commented Dec 6, 2025

Copy link
Copy Markdown
Member

Sure, in this case and any others, whenever you want.

Fidget-Spinner reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fidget-Spinner

Fidget-Spinner commented Dec 6, 2025

Copy link
Copy Markdown
Member

@caje731 please add a test case to Lib/test/test_capi/test_opt.py by copying the script from here #141786 (comment). You can take a look at test_interpreter_finalization_with_generator_alive to see how to run a test in a subprocess easily.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

caje731 added 3 commits December 8, 2025 10:13
@caje731
pythongh-141786 Add a test case
36a6252
@caje731
pythongh-141786 Fix an incorrect condition
ade01a2
@caje731
pythongh-141786 Fix test name to be more precise
7ab1b35
@caje731

caje731 commented Dec 8, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

I should note that the following simple diff in the test:

diff --git a/Lib/test/test_capi/test_opt.py b/Lib/test/test_capi/test_opt.py
index 0f67f19a115..9027be79254 100644
--- a/Lib/test/test_capi/test_opt.py
+++ b/Lib/test/test_capi/test_opt.py
@@ -2772,7 +2772,7 @@ def B(B):
                if rand.random() < 0.1:
                    C(B)

-            for D in range(200):
+            for D in range(350):
                try:
                    B(D)
                except:

produces a breakage in the test:

...
stderr:
---
Traceback (most recent call last):
  File "<string>", line 136, in <module>
    b()
    ~^^
  File "<string>", line 101, in b
    del B
        ^
UnboundLocalError: cannot access local variable 'B' where it is not associated with a value
---

At this point I'm unsure if this is related to JIT optimizations, but superficially seems to be just a side-effect of the symbol-conflicts (ab)used in the test.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fidget-Spinner

Fidget-Spinner commented Dec 11, 2025 •
edited by efimov-mikhail
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

@markshannon i would like to merge this still. Even with your proposed fix it's possible to invalidate an executor while tracing. This is a separate issue.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fidget-Spinner Fidget-Spinner closed this Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@caje731 @Fidget-Spinner @devdanzin
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.