gh-99110: Initialize frame->previous in init_frame to fix segmentation fault when accessing frame.f_back (#100182)

This commit is contained in:
Bill Fisher 2022-12-23 07:45:53 -07:00 committed by GitHub
parent 2659036c75
commit 88d565f32a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 1 deletions

View file

@ -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()