Skip to content

Commit

Permalink
Stackless issue python#227: Protect climb_stack_and_eval_frame from t…
Browse files Browse the repository at this point in the history
…rivialization

gcc >= 4.7 trivializes not only climb_stack_and_transfer, but also climb_stack_and_eval_frame.

Thus the same global-write trick must be used both there and here.
  • Loading branch information
mmirate authored and Anselm Kruis committed Aug 23, 2019
1 parent 908439c commit 836b2c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Stackless/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ What's New in Stackless 2.7.XX?

*Release date: XXXX-XX-XX*

- https://github.com/stackless-dev/stackless/issues/227
Protect climb_stack_and_eval_frame from trivialization.
gcc-4.8.5 (and possibly other versions between 4.7 and 5.4) trivializes a
side-effect-only alloca. Patch by Milo Mirate.

- https://github.com/stackless-dev/stackless/issues/220
Improve the error handling in case of failed stack transfers / hard tasklet
switches. Call Py_FatalError, if a clean recovery is impossible.
Expand Down
6 changes: 6 additions & 0 deletions Stackless/core/stacklesseval.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ make_initial_stub(void)
return result;
}

/* a write only variable used to prevent overly optimisation */
intptr_t *global_goobledigoobs;
static PyObject *
climb_stack_and_eval_frame(PyFrameObject *f)
{
Expand All @@ -286,6 +288,10 @@ climb_stack_and_eval_frame(PyFrameObject *f)
goobledigoobs = alloca(needed * sizeof(intptr_t));
if (goobledigoobs == NULL)
return NULL;
/* hinder the compiler to optimise away
goobledigoobs and the alloca call.
This happens with gcc 4.7.x and -O2 */
global_goobledigoobs = goobledigoobs;
}
return slp_eval_frame(f);
}
Expand Down

0 comments on commit 836b2c4

Please sign in to comment.