Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fix skewed stack trackes in the Tachyon profiler when caching is enabled and
when generators and coroutines are profiled, by updating
``tstate->last_profiled_frame`` at every frame-removal site. The issue resulted
in total erasure of some callers. Patch by Maurycy Pawłowski-Wieroński.
9 changes: 9 additions & 0 deletions Modules/_testinternalcapi/test_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Objects/genobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,9 @@ _gen_throw(PyGenObject *gen, int close_on_genexit,
'yield from' or awaiting on with 'await'. */
ret = _gen_throw((PyGenObject *)yf, close_on_genexit,
typ, val, tb);
if (tstate->last_profiled_frame == frame) {
tstate->last_profiled_frame = prev;
}
tstate->current_frame = prev;
frame->previous = NULL;
}
Expand All @@ -701,6 +704,9 @@ _gen_throw(PyGenObject *gen, int close_on_genexit,
frame->previous = prev;
tstate->current_frame = frame;
ret = PyObject_CallFunctionObjArgs(meth, typ, val, tb, NULL);
if (tstate->last_profiled_frame == frame) {
tstate->last_profiled_frame = prev;
}
tstate->current_frame = prev;
frame->previous = NULL;
Py_DECREF(meth);
Expand Down
6 changes: 6 additions & 0 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1860,6 +1860,9 @@ dummy_func(
gen->gi_exc_state.previous_item = NULL;
_Py_LeaveRecursiveCallPy(tstate);
_PyInterpreterFrame *gen_frame = frame;
if (tstate->last_profiled_frame == gen_frame) {
tstate->last_profiled_frame = gen_frame->previous;
}
frame = tstate->current_frame = frame->previous;
gen_frame->previous = NULL;
((_PyThreadStateImpl *)tstate)->generator_return_kind = GENERATOR_YIELD;
Expand Down Expand Up @@ -5874,6 +5877,9 @@ dummy_func(
gen_frame->owner = FRAME_OWNED_BY_GENERATOR;
_Py_LeaveRecursiveCallPy(tstate);
_PyInterpreterFrame *prev = frame->previous;
if (tstate->last_profiled_frame == frame) {
tstate->last_profiled_frame = prev;
}
_PyThreadState_PopFrame(tstate, frame);
frame = tstate->current_frame = prev;
LOAD_IP(frame->return_offset);
Expand Down
3 changes: 3 additions & 0 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -2006,6 +2006,9 @@ _PyEvalFramePushAndInit(PyThreadState *tstate, _PyStackRef func,
_PyFrame_Initialize(tstate, frame, func, locals, code, 0, previous);
if (initialize_locals(tstate, func_obj, frame->localsplus, args, argcount, kwnames)) {
assert(frame->owner == FRAME_OWNED_BY_THREAD);
if (tstate->last_profiled_frame == frame) {
tstate->last_profiled_frame = tstate->current_frame;
}
clear_thread_frame(tstate, frame);
return NULL;
}
Expand Down
6 changes: 6 additions & 0 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading