8000 GH-123185: Check for `NULL` after calling `_PyEvalFramePushAndInit` (… · python/cpython@1eba8ba · GitHub
[go: up one dir, main page]

Skip to content

Commit 1eba8ba

Browse files
authored
GH-123185: Check for NULL after calling _PyEvalFramePushAndInit (GH-123194)
1 parent 90c892e commit 1eba8ba

File tree

5 files changed

+29
-4
lines changed

5 files changed

+29
-4
lines changed

Include/internal/pycore_uop_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/test/test_class.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,19 @@ def __init__(self, obj):
787787
Type(i)
788788
self.assertEqual(calls, 100)
789789

790+
def test_specialization_class_call_doesnt_crash(self):
791+
# gh-123185
792+
793+
class Foo:
794+
def __init__(self, arg):
795+
pass
796+
797+
for _ in range(8):
798+
try:
799+
Foo()
800+
except:
801+
pass
802+
790803

791804
from _testinternalcapi import has_inline_values
792805

Python/bytecodes.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3584,8 +3584,12 @@ dummy_func(
35843584
args[-1] = self;
35853585
init_frame = _PyEvalFramePushAndInit(
35863586
tstate, init_func, NULL, args-1, oparg+1, NULL, shim);
3587-
frame->return_offset = 1 + INLINE_CACHE_ENTRIES_CALL;
35883587
SYNC_SP();
3588+
if (init_frame == NULL) {
3589+
_PyEval_FrameClearAndPop(tstate, shim);
3590+
ERROR_NO_POP();
3591+
}
3592+
frame->return_offset = 1 + INLINE_CACHE_ENTRIES_CALL;
35893593
/* Account for pushing the extra frame.
35903594
* We don't check recursion depth here,
35913595
* as it will be checked after start_frame */

Python/executor_cases.c.h

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
0