10000 [3.11] GH-96754: Check whether the interpreter frame is complete before creating frame object. (GH-96776) by miss-islington · Pull Request #96787 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.11] GH-96754: Che 8000 ck whether the interpreter frame is complete before creating frame object. (GH-96776) #96787

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 13, 2022
Merged
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
GH-96754: Check whether the interpreter frame is complete before crea…
…ting frame object. (GH-96776)

(cherry picked from commit 12c5f32)

Co-authored-by: Mark Shannon <mark@hotpy.org>
  • Loading branch information
markshannon authored and miss-islington committed Sep 13, 2022
commit e28cce6481dd3db679e2244c9fb0e857b1bfc2bc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Make sure that all frame objects created are created from valid interpreter
frames. Prevents the possibility of invalid frames in backtraces and signal
handlers.
3 changes: 3 additions & 0 deletions Modules/signalmodule.c
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1832,6 +1832,9 @@ _PyErr_CheckSignalsTstate(PyThreadState *tstate)
_Py_atomic_store(&is_tripped, 0);

_PyInterpreterFrame *frame = tstate->cframe->current_frame;
while (frame && _PyFrame_IsIncomplete(frame)) {
frame = frame->previous;
}
signal_state_t *state = &signal_global_state;
for (int i = 1; i < Py_NSIG; i++) {
if (!_Py_atomic_load_relaxed(&Handlers[i].tripped)) {
Expand Down
8 changes: 5 additions & 3 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -5747,9 +5747,11 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
#endif

/* Log traceback info. */
PyFrameObject *f = _PyFrame_GetFrameObject(frame);
if (f != NULL) {
PyTraceBack_Here(f);
if (!_PyFrame_IsIncomplete(frame)) {
PyFrameObject *f = _PyFrame_GetFrameObject(frame);
if (f != NULL) {
PyTraceBack_Here(f);
}
}

if (tstate->c_tracefunc != NULL) {
Expand Down
3 changes: 3 additions & 0 deletions Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,9 @@ _PyThread_CurrentFrames(void)
PyThreadState *t;
for (t = i->threads.head; t != NULL; t = t->next) {
_PyInterpreterFrame *frame = t->cframe->current_frame;
while (frame && _PyFrame_IsIncomplete(frame)) {
frame = frame->previous;
}
if (frame == NULL) {
continue;
}
Expand Down
0