--- /dev/null
+Make sure that all frame objects created are created from valid interpreter
+frames. Prevents the possibility of invalid frames in backtraces and signal
+handlers.
_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)) {
#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) {
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;
}