]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-108487: Move assert(self != NULL) down beyond DEOPT_IF() (#108510)
authorGuido van Rossum <guido@python.org>
Mon, 28 Aug 2023 17:17:00 +0000 (10:17 -0700)
committerGitHub <noreply@github.com>
Mon, 28 Aug 2023 17:17:00 +0000 (10:17 -0700)
Misc/NEWS.d/next/Core and Builtins/2023-08-26-04-31-01.gh-issue-108487.1Gbr9k.rst [new file with mode: 0644]
Python/bytecodes.c
Python/generated_cases.c.h

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 (file)
index 0000000..277b7c0
--- /dev/null
@@ -0,0 +1 @@
+Move an assert that would cause a spurious crash in a devious case that should only trigger deoptimization.
index a55460afea751ccca7909db80c5a17fb92ef2ab9..93926c03421eb73e4c4a8a8a57152625f84c76c6 100644 (file)
@@ -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) {
index 3f46f1a10a247f6a4124f6c08da8bb6cc803935a..5940c185817604efc819f4e56f8482a75719b9f4 100644 (file)
             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) {