Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 874c948

Browse files
author
Anselm Kruis
committed
Stackless issue #249: Mitigate usage of PEP 523 frame evaluation API
Stackless does not support custom frame evaluation functions defined by PEP 523. If an extension module sets a custom frame evaluation function, Stackless now terminates to prevent undefined behavior. (cherry picked from commit d57b317)
1 parent bed2233 commit 874c948

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Python/ceval.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4071,6 +4071,16 @@ PyEval_EvalFrameEx_slp(PyFrameObject *f, int throwflag, PyObject *retval)
40714071
{
40724072
PyThreadState *tstate = PyThreadState_GET();
40734073

4074+
/* Check, if an extension module has changed tstate->interp->eval_frame.
4075+
* PEP 523 defines this function pointer as an API to customise the frame
4076+
* evaluation. Stackless can not support this API. In order to prevent
4077+
* undefined behavior, we terminate the interpreter.
4078+
*/
4079+
if (tstate->interp->eval_frame != _PyEval_EvalFrameDefault)
4080+
Py_FatalError("An extension module has set a custom frame evaluation function (see PEP 523).\n"
4081+
"Stackless Python does not support the frame evaluation API defined by PEP 523.\n"
4082+
"The programm now terminates to prevent undefined behavior.\n");
4083+
40744084
/* Start of code, similar to non stackless
40754085
* PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
40764086
*/

Stackless/changelog.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ What's New in Stackless 3.X.X?
99

1010
*Release date: 20XX-XX-XX*
1111

12+
- https://github.com/stackless-dev/stackless/issues/249
13+
Stackless does not support custom frame evaluation functions defined by
14+
PEP 523. If an extension module sets a custom frame evaluation function,
15+
Stackless now terminates to prevent undefined behavior.
16+
1217
- https://github.com/stackless-dev/stackless/issues/248
1318
Documentation update: Mention, that module "stackless" must be imported, to
1419
enable the extended pickling capabilities.

0 commit comments

Comments
 (0)