Issue 22851: 2.7 core crashes with generator.gi_frame.f_restricted (original) (raw)

Issue22851

Created on 2014-11-12 10:20 by doko, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 9348 merged ZackerySpytz,2018-09-17 10:44
Messages (6)
msg231069 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2014-11-12 10:20
seen with the current 2.7 branch: $ cat > x.py def foo(): yield gen = foo() print gen.gi_frame.f_restricted for i in gen: pass print gen.gi_frame gen = foo() print gen.next() print gen.gi_frame.f_restricted $ python x.py False None None Segmentation fault Program received signal SIGSEGV, Segmentation fault. 0x0000000000462b44 in frame_getrestricted ( f=Frame 0x7ffff7f58410, for file x.py, line 1, in foo (), closure=0x0) at ../Objects/frameobject.c:383 383 ../Objects/frameobject.c: No such file or directory. (gdb) bt #0 0x0000000000462b44 in frame_getrestricted ( f=Frame 0x7ffff7f58410, for file x.py, line 1, in foo (), closure=0x0) at ../Objects/frameobject.c:383
msg231072 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2014-11-12 11:38
This is related to the fix for issue 14432. gen_send_ex sets f->f_tstate to NULL, so PyFrame_IsRestricted segfaults: #define PyFrame_IsRestricted(f) \ ((f)->f_builtins != (f)->f_tstate->interp->builtins)
msg231075 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-11-12 12:57
Related change: New changeset aa324af42c0e by Victor Stinner in branch '2.7': Issue #14432: Generator now clears the borrowed reference to the thread state http://hg.python.org/cpython/rev/aa324af42c0e
msg231186 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-11-14 21:16
This appears to be 2.7 only as 3.4.2 stops on the first print with AttributeError: 'frame' object has no attribute 'f_restricted', which is not a crash.
msg231193 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2014-11-14 22:20
The fix for issue 14432 was applied to 3.3, but I'm pretty sure 2.x PyFrame_IsRestricted is the only problem. Nothing else should see f_tstate when it's NULL. Also, f_tstate was dropped from PyFrameObject in 3.4.
msg327643 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-10-13 09:25
New changeset 68ddb59417ee0b0dedf5c8b66a304138c9ce0a63 by Serhiy Storchaka (Zackery Spytz) in branch '2.7': [2.7] bpo-22851: Fix a segfault when accessing generator.gi_frame.f_restricted. (GH-9348) https://github.com/python/cpython/commit/68ddb59417ee0b0dedf5c8b66a304138c9ce0a63
History
Date User Action Args
2022-04-11 14:58:10 admin set github: 67040
2018-10-26 08:14:40 serhiy.storchaka link issue21967 superseder
2018-10-13 09:28:43 serhiy.storchaka set status: open -> closedresolution: fixedstage: patch review -> resolved
2018-10-13 09:25:13 serhiy.storchaka set nosy: + serhiy.storchakamessages: +
2018-09-17 10:44:29 ZackerySpytz set nosy: + ZackerySpytz
2018-09-17 10:44:04 ZackerySpytz set keywords: + patchstage: needs patch -> patch reviewpull_requests: + <pull%5Frequest8771>
2014-11-15 00:20:17 Arfrever set nosy: + Arfrever
2014-11-14 22:20:32 eryksun set messages: +
2014-11-14 21:16:38 terry.reedy set nosy: + terry.reedytitle: core crashes -> 2.7 core crashes with generator.gi_frame.f_restrictedmessages: + stage: needs patch
2014-11-12 12:57:50 vstinner set messages: +
2014-11-12 11:38:14 eryksun set nosy: + eryksunmessages: +
2014-11-12 10:26:19 vstinner set nosy: + vstinner
2014-11-12 10:20:31 doko create