Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-141786: Fix missing parent executor during JIT trace#142344

Open
caje731 wants to merge 4 commits intopython:mainfrom
caje731:gh-141786
Open

gh-141786: Fix missing parent executor during JIT trace#142344
caje731 wants to merge 4 commits intopython:mainfrom
caje731:gh-141786

Conversation

@caje731
Copy link
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 issuegh-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.

An executor's trace can point to another executor, forming a graphof traces / executors. Sometimes it is possible while recording atrace that the parent executor is freed / invalidated halfway. Thisleads to the bug described in the issuepythongh-141786, which if leftunfixed could cause a memory leak.This patch checks for the validity of the parent executor as wellas allowing JIT from the cold executor. While the cold executor isnot linked, it is the executor responsible for creating side tracesand we still want to JIT from it.
@caje731
Copy link
ContributorAuthor

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

@Fidget-Spinner
Copy link
Member

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

@devdanzin
Copy link
Member

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

Fidget-Spinner reacted with thumbs up emoji

@Fidget-Spinner
Copy link
Member

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

@caje731
Copy link
ContributorAuthor

caje731 commentedDec 8, 2025
edited
Loading

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.pyindex 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.

@Fidget-Spinner
Copy link
Member

Fidget-Spinner commentedDec 11, 2025
edited by efimov-mikhail
Loading

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

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@markshannonmarkshannonAwaiting requested review from markshannonmarkshannon is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@caje731@Fidget-Spinner@devdanzin

[8]ページ先頭

©2009-2026 Movatter.jp