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

Commit 3629160

Browse files
author
Anselm Kruis
committed
Stackless issue #200: fix PyTasklet_Run_nr() and PyTasklet_Switch_nr()
Fix a bug in the C-API functions PyTasklet_Run_nr() and PyTasklet_Switch_nr(). Under exotic conditions the functions could cause undefined behavior.
1 parent 9264f0d commit 3629160

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

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/200
13+
Fix a bug in the C-API functions PyTasklet_Run_nr() and
14+
PyTasklet_Switch_nr(). Under exotic conditions the functions could
15+
cause undefined behavior.
16+
1217
- https://github.com/stackless-dev/stackless/issues/196
1318
Stackless can now pickle coroutine_wrapper objects.
1419

Stackless/module/taskletobject.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,8 @@ impl_tasklet_run_remove(PyTaskletObject *task, int remove);
936936
int
937937
PyTasklet_Run_nr(PyTaskletObject *task)
938938
{
939-
(_PyRuntime.st.try_stackless) = 1;
939+
PyThreadState *ts = PyThreadState_GET();
940+
STACKLESS_PROPOSE_ALL(ts);
940941
return slp_return_wrapper(impl_tasklet_run_remove(task, 0));
941942
}
942943

@@ -1061,7 +1062,8 @@ PyTasklet_Switch_M(PyTaskletObject *task)
10611062
int
10621063
PyTasklet_Switch_nr(PyTaskletObject *task)
10631064
{
1064-
(_PyRuntime.st.try_stackless) = 1;
1065+
PyThreadState *ts = PyThreadState_GET();
1066+
STACKLESS_PROPOSE_ALL(ts);
10651067
return slp_return_wrapper(impl_tasklet_run_remove(task, 1));
10661068
}
10671069

0 commit comments

Comments
 (0)