Skip to content

Commit bbdd889

Browse files
[3.12] gh-108487: Change assert that should've been DEOPT_IF (#108509)
* Remove assert that should've been DEOPT_IF The assert(method != NULL) in CALL_NO_KW_LIST_APPEND is wrong -- this condition should lead to a deoptimization, and indeed there is a DEOPT_IF two lines later that will trigger if method == NULL. This would crash in a devious repro scenario (first seen live in boto3 tests) when compiled with assertions enabled. In a production version there is no crash, so impact is limited. (The crash also appears in main; I will prepare a separate PR.) * Add back a different assert(self != NULL) * 📜🤖 Added by blurb_it. --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
1 parent 208741c commit bbdd889

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Change an assert that would cause a spurious crash in a devious case that should only trigger deoptimization.

Python/bytecodes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2992,9 +2992,9 @@ dummy_func(
29922992
inst(CALL_NO_KW_LIST_APPEND, (unused/1, unused/2, method, self, args[oparg] -- unused)) {
29932993
assert(kwnames == NULL);
29942994
assert(oparg == 1);
2995-
assert(method != NULL);
29962995
PyInterpreterState *interp = _PyInterpreterState_GET();
29972996
DEOPT_IF(method != interp->callable_cache.list_append, CALL);
2997+
assert(self != NULL);
29982998
DEOPT_IF(!PyList_Check(self), CALL);
29992999
STAT_INC(CALL, hit);
30003000
if (_PyList_AppendTakeRef((PyListObject *)self, args[0]) < 0) {

Python/generated_cases.c.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.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy