summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_frame.py
diff options
context:
space:
mode:
authorBill Fisher <william.w.fisher@gmail.com>2022-12-23 14:45:53 (GMT)
committerGitHub <noreply@github.com>2022-12-23 14:45:53 (GMT)
commit88d565f32a709140664444c6dea20ecd35a10e94 (patch)
treebd185455ee0b70ed60f6ca29479f2fb918999599 /Lib/test/test_frame.py
parent2659036c757a11235c4abd21f02c3a548a344fe7 (diff)
downloadcpython-88d565f32a709140664444c6dea20ecd35a10e94.zip
cpython-88d565f32a709140664444c6dea20ecd35a10e94.tar.gz
cpython-88d565f32a709140664444c6dea20ecd35a10e94.tar.bz2
gh-99110: Initialize `frame->previous` in init_frame to fix segmentation fault when accessing `frame.f_back` (#100182)
Diffstat (limited to 'Lib/test/test_frame.py')
-rw-r--r--Lib/test/test_frame.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_frame.py b/Lib/test/test_frame.py
index ed413f1..40c734b 100644
--- a/Lib/test/test_frame.py
+++ b/Lib/test/test_frame.py
@@ -408,6 +408,15 @@ class TestCAPI(unittest.TestCase):
frame = next(gen)
self.assertIs(gen, _testcapi.frame_getgenerator(frame))
+ def test_frame_fback_api(self):
+ """Test that accessing `f_back` does not cause a segmentation fault on
+ a frame created with `PyFrame_New` (GH-99110)."""
+ def dummy():
+ pass
+
+ frame = _testcapi.frame_new(dummy.__code__, globals(), locals())
+ # The following line should not cause a segmentation fault.
+ self.assertIsNone(frame.f_back)
if __name__ == "__main__":
unittest.main()