summaryrefslogtreecommitdiffstats
path: root/Python/optimizer_analysis.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2024-02-29 18:55:29 (GMT)
committerGitHub <noreply@github.com>2024-02-29 18:55:29 (GMT)
commit0656509033948780e6703391daca773c779041f7 (patch)
treef75c2c923b52ee8367c9f033cb911ac8dc99bfca /Python/optimizer_analysis.c
parent3b6f4cadf19e6a4edd2cbbbc96a0a4024b395648 (diff)
downloadcpython-0656509033948780e6703391daca773c779041f7.zip
cpython-0656509033948780e6703391daca773c779041f7.tar.gz
cpython-0656509033948780e6703391daca773c779041f7.tar.bz2
gh-116088: Insert bottom checks after all sym_set_...() calls (#116089)
This changes the `sym_set_...()` functions to return a `bool` which is `false` when the symbol is `bottom` after the operation. All calls to such functions now check this result and go to `hit_bottom`, a special error label that prints a different message and then reports that it wasn't able to optimize the trace. No executor will be produced in this case.
Diffstat (limited to 'Python/optimizer_analysis.c')
-rw-r--r--Python/optimizer_analysis.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/Python/optimizer_analysis.c b/Python/optimizer_analysis.c
index 2a7ef4e..a326e22 100644
--- a/Python/optimizer_analysis.c
+++ b/Python/optimizer_analysis.c
@@ -363,6 +363,15 @@ error:
DPRINTF(1, "Encountered error in abstract interpreter\n");
_Py_uop_abstractcontext_fini(ctx);
return 0;
+
+hit_bottom:
+ // Attempted to push a "bottom" (contradition) symbol onto the stack.
+ // This means that the abstract interpreter has hit unreachable code.
+ // We *could* generate an _EXIT_TRACE or _FATAL_ERROR here, but it's
+ // simpler to just admit failure and not create the executor.
+ DPRINTF(1, "Hit bottom in abstract interpreter\n");
+ _Py_uop_abstractcontext_fini(ctx);
+ return 0;
}