From: Guido van Rossum Date: Mon, 28 Aug 2023 17:17:00 +0000 (-0700) Subject: gh-108487: Move assert(self != NULL) down beyond DEOPT_IF() (#108510) X-Git-Tag: v3.13.0a1~740 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=47d7eba889bc03884744f978f5f8612380363332;p=thirdparty%2FPython%2Fcpython.git gh-108487: Move assert(self != NULL) down beyond DEOPT_IF() (#108510) --- diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-08-26-04-31-01.gh-issue-108487.1Gbr9k.rst b/Misc/NEWS.d/next/Core and Builtins/2023-08-26-04-31-01.gh-issue-108487.1Gbr9k.rst new file mode 100644 index 000000000000..277b7c067e25 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2023-08-26-04-31-01.gh-issue-108487.1Gbr9k.rst @@ -0,0 +1 @@ +Move an assert that would cause a spurious crash in a devious case that should only trigger deoptimization. diff --git a/Python/bytecodes.c b/Python/bytecodes.c index a55460afea75..93926c03421e 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -3346,9 +3346,9 @@ dummy_func( inst(CALL_NO_KW_LIST_APPEND, (unused/1, unused/2, callable, self, args[oparg] -- unused)) { ASSERT_KWNAMES_IS_NULL(); assert(oparg == 1); - assert(self != NULL); PyInterpreterState *interp = tstate->interp; DEOPT_IF(callable != interp->callable_cache.list_append, CALL); + assert(self != NULL); DEOPT_IF(!PyList_Check(self), CALL); STAT_INC(CALL, hit); if (_PyList_AppendTakeRef((PyListObject *)self, args[0]) < 0) { diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 3f46f1a10a24..5940c1858176 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -4412,9 +4412,9 @@ callable = stack_pointer[-2 - oparg]; ASSERT_KWNAMES_IS_NULL(); assert(oparg == 1); - assert(self != NULL); PyInterpreterState *interp = tstate->interp; DEOPT_IF(callable != interp->callable_cache.list_append, CALL); + assert(self != NULL); DEOPT_IF(!PyList_Check(self), CALL); STAT_INC(CALL, hit); if (_PyList_AppendTakeRef((PyListObject *)self, args[0]) < 0) {