Skip to content

Conversation

@caje731
Copy link
Contributor

@caje731 caje731 commented Dec 6, 2025

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.

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
Copy link
Contributor Author

caje731 commented Dec 6, 2025

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

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