Skip to content

Commit ac6e156

Browse files
author
Anselm Kruis
committed
Stackless issue python#221: Change C-stack serial numbers to 64bit
These numbers were already 64bit if available until the relevant preprocessor macro was renamed. This change affects Stackless structures PyStacklessState and PyCStackObject. Extension authors usually don't access them directly. (cherry picked from commit ce8faba)
1 parent 5b7a88f commit ac6e156

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

Include/slp_structs.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,7 @@ typedef struct _cstack {
143143
PyObject_VAR_HEAD
144144
struct _cstack *next;
145145
struct _cstack *prev;
146-
#ifdef have_long_long
147-
long_long serial;
148-
#else
149-
long serial;
150-
#endif
146+
PY_LONG_LONG serial;
151147
struct _tasklet *task;
152148
int nesting_level;
153149
PyThreadState *tstate;

Include/slp_tstate.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,8 @@ typedef struct _sts {
7676
* stack belongs. This is used to find out if a stack switch
7777
* is required when the main tasklet exits
7878
*/
79-
#ifdef have_long_long
80-
long_long serial;
81-
long_long serial_last_jump;
82-
#else
83-
long serial;
84-
long serial_last_jump;
85-
#endif
79+
PY_LONG_LONG serial;
80+
PY_LONG_LONG serial_last_jump;
8681
/* the blueprint for new stacks */
8782
struct _cstack *initial_stub;
8883
/* the base address for hijacking stacks. XXX deprecating */

Stackless/changelog.txt

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

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

12+
- https://github.com/stackless-dev/stackless/issues/221
13+
Change the width of C-stack serial numbers to 64bit. This prevents overflows
14+
in long running applications with an embedded Stackless Python.
15+
This change affects internal Stackless C structures PyStacklessState and
16+
PyCStackObject. If you tamper with them, you must recompile your code!
17+
1218
- https://github.com/stackless-dev/stackless/issues/219
1319
Fix a NULL pointer access in PyStackless_Schedule, if this function is called
1420
from from "outside" and if no current tasklet exists.

Stackless/module/stacklessmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ test_outside(PyObject *self)
936936
int recursion_depth = ts->recursion_depth;
937937
int nesting_level = ts->st.nesting_level;
938938
PyObject *ret = Py_None;
939-
int jump = ts->st.serial_last_jump;
939+
PY_LONG_LONG jump = ts->st.serial_last_jump;
940940

941941
Py_INCREF(ret);
942942
ts->st.main = NULL;

0 commit comments

Comments
 (0)