Visitar URL original
Stackless issue #227: Protect climb_stack_and_eval_frame from trivial… · akruis/cpython@836b2c4 · GitHub
Skip to content

Commit 836b2c4

Browse files
mmirateAnselm Kruis
authored andcommitted
Stackless issue python#227: Protect climb_stack_and_eval_frame from trivialization
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.
1 parent 908439c commit 836b2c4

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎Stackless/changelog.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ What's New in Stackless 2.7.XX?
1010

1111
*Release date: XXXX-XX-XX*
1212

13+
- https://github.com/stackless-dev/stackless/issues/227
14+
Protect climb_stack_and_eval_frame from trivialization.
15+
gcc-4.8.5 (and possibly other versions between 4.7 and 5.4) trivializes a
16+
side-effect-only alloca. Patch by Milo Mirate.
17+
1318
- https://github.com/stackless-dev/stackless/issues/220
1419
Improve the error handling in case of failed stack transfers / hard tasklet
1520
switches. Call Py_FatalError, if a clean recovery is impossible.

‎Stackless/core/stacklesseval.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ make_initial_stub(void)
267267
return result;
268268
}
269269

270+
/* a write only variable used to prevent overly optimisation */
271+
intptr_t *global_goobledigoobs;
270272
static PyObject *
271273
climb_stack_and_eval_frame(PyFrameObject *f)
272274
{
@@ -286,6 +288,10 @@ climb_stack_and_eval_frame(PyFrameObject *f)
286288
goobledigoobs = alloca(needed * sizeof(intptr_t));
287289
if (goobledigoobs == NULL)
288290
return NULL;
291+
/* hinder the compiler to optimise away
292+
goobledigoobs and the alloca call.
293+
This happens with gcc 4.7.x and -O2 */
294+
global_goobledigoobs = goobledigoobs;
289295
}
290296
return slp_eval_frame(f);
291297
}

0 commit comments

Comments
 (0)