Skip to content

Commit 6272957

Browse files
committed
Reset thread state pointer after detaching a thread
1 parent 502b23e commit 6272957

File tree

1 file changed

+7
-0
lines changed
  • graalpython/com.oracle.graal.python.cext/src

1 file changed

+7
-0
lines changed

graalpython/com.oracle.graal.python.cext/src/pystate.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@ PyGILState_Release(PyGILState_STATE oldstate)
187187
if (graalpy_gilstate_counter == 0 && graalpy_attached_thread) {
188188
(*TRUFFLE_CONTEXT)->detachCurrentThread(TRUFFLE_CONTEXT);
189189
graalpy_attached_thread = 0;
190+
#ifndef GRAALVM_PYTHON_LLVM_MANAGED
191+
/*
192+
* The thread state on the Java-side can get garbage collected after the thread is detached,
193+
* so we need to make sure to fetch a fresh pointer the next time we attach.
194+
*/
195+
tstate_current = NULL;
196+
#endif /* GRAALVM_PYTHON_LLVM_MANAGED */
190197
}
191198
}
192199
}

0 commit comments

Comments
 (0)