1. Ronny Pfannschmidt
  2. greenlet-excstate


Alexey Borzenkov  committed 6b91d3e

Fix random VC90 crashes, volatile

It turns out that volatile is needed on ts_current and ts_passaround_*
What happens is that these globals are marked static, so compiler knows
these cannot be changed by external calls into Python, and optimizer
may get confused, because in truth they can (and do!) change when stack
is switched. In reality we don't need to make them volatile, not making
them static also works, but I'm reluctant about introducing new public

  • Participants
  • Parent commits e1550ce
  • Branches default

Comments (0)

Files changed (1)

File greenlet.c

View file
  • Ignore whitespace
 extern PyTypeObject PyGreenlet_Type;
 /* The current greenlet in this thread state (holds a reference) */
-static PyGreenlet* ts_current = NULL;
+static PyGreenlet* volatile ts_current = NULL;
 /* Holds a reference to the switching-from stack during the slp switch */
 static PyGreenlet* ts_origin = NULL;
 /* Holds a reference to the switching-to stack during the slp switch */
 static PyGreenlet* ts_target = NULL;
 /* NULL if error, otherwise args tuple to pass around during slp switch */
-static PyObject* ts_passaround_args = NULL;
-static PyObject* ts_passaround_kwargs = NULL;
+static PyObject* volatile ts_passaround_args = NULL;
+static PyObject* volatile ts_passaround_kwargs = NULL;
 /* Thread-aware routines, switching global variables when needed */