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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
caje731 wants to merge4 commits intopython:main
base:main
Choose a base branch
Loading
fromcaje731:gh-141786
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 138 additions & 0 deletionsLib/test/test_capi/test_opt.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2695,6 +2695,144 @@ def recursive_wrapper_4569():
pass
"""))

def test_executor_invalidation_does_not_crash(self):
script_helper.assert_python_ok("-c", textwrap.dedent("""
import random

rand = random.Random(38720)
import sys

def b():
for c in range(23):
rand.random()
rand.random()
if rand.random() > 0.1:
rand.random()
rand.random()
rand.random()
for c in range(4):
rand.random()
if rand.random():
0
if rand.random() > 0.1:
rand.random()
rand.random()
if rand.random():
rand.random()
if rand.random():
rand.random()
rand.random()
if rand.random():
rand.random()
rand.random()
if rand.random():
if rand.random() > 0.1:
rand.random()
if rand.random() < rand.random():
...
if rand.random() < rand.random():
...
if rand.random():
...
if rand.random() > 0.1:
rand.random()
rand.random()
for c in range(12):
rand.random()

def random(B):
if rand.random() < 0.1:
random(B)

def Random(B):
if rand.random():
random(B)

def b(B):
if rand.random():
Random(B)

def c(B):
if rand.random() < 0.1:
b(B)

def a(B):
if rand.random() > 0.1:
c(B)

def A(B):
if rand.random() > 0.1:
a(B)

def C(B):
if rand.random() > 0.1:
A(B)

def B(B):
if rand.random() < 0.1:
C(B)

for D in range(200):
try:
B(D)
except:
...

class A:
def __del__(C):
b = sys._getframe(1)
exec("D=0", b.f_globals, b.f_locals)

B = A()
if rand.random() < 0.1:
if rand.random() < 0.1:
if rand.random() < 0.1:
for D in range(D):
if rand.random() < 0.1:
if rand.random() > 0.1:
if rand.random():
if rand.random() > rand.random():
C
if rand.random() < 0.1:
if rand.random() < 0.1:
if rand.random() < 0.1:
del B
if rand.random() < 0.1:
if rand.random() < 0.1:
if rand.random():
0
if rand.random() > 0.1:
if rand.random() > 0.1:
rand.random()
rand.random()
if rand.random() > 0.1:
rand.random()
rand.random()
if rand.random() > 0.1:
if rand.random() > 0.1:
rand.random()
rand.random()
rand.random()
rand.random()
if rand.random() > 0.1:
if rand.random() > 0.1:
rand.random()
if rand.random() > rand.random():
0
if rand.random():
C
if rand.random() > 0.1:
rand.random()
rand.random()
for c in range(3):
if rand.random():
0
for c in range(2):
rand.random()

for D in range(5064):
b()
"""))

def global_identity(x):
return x
Expand Down
4 changes: 3 additions & 1 deletionPython/ceval.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1408,7 +1408,9 @@ stop_tracing_and_jit(PyThreadState *tstate, _PyInterpreterFrame *frame)
// Likewise, we hold a strong reference to the executor containing this exit, so the exit is guaranteed
// to be valid to access.
if (err <= 0) {
exit->temperature = restart_backoff_counter(exit->temperature);
if (exit->executor->vm_data.linked && exit->executor->vm_data.valid) {
exit->temperature = restart_backoff_counter(exit->temperature);
}
}
else {
exit->temperature = initial_temperature_backoff_counter();
Expand Down
9 changes: 8 additions & 1 deletionPython/optimizer.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -140,6 +140,14 @@ _PyOptimizer_Optimize(
}
assert(!interp->compiling);
assert(_tstate->jit_tracer_state.initial_state.stack_depth >= 0);
_PyExitData *exit = _tstate->jit_tracer_state.initial_state.exit;
_PyExecutorObject *cold_executor = _PyExecutor_GetColdExecutor();
if (exit != NULL &&
(!exit->executor->vm_data.linked || !exit->executor->vm_data.valid) &&
exit->executor != cold_executor) {
// gh-141786 Parent executor is either unlinked or invalid - cannot optimize.
return 0;
}
#ifndef Py_GIL_DISABLED
assert(_tstate->jit_tracer_state.initial_state.func != NULL);
interp->compiling = true;
Expand DownExpand Up@@ -185,7 +193,6 @@ _PyOptimizer_Optimize(
else {
executor->vm_data.code = NULL;
}
_PyExitData *exit = _tstate->jit_tracer_state.initial_state.exit;
if (exit != NULL) {
exit->executor = executor;
}
Expand Down
Loading

[8]ページ先頭

©2009-2026 Movatter.jp