Skip to content

Commit 9b1eaf6

Browse files
committed
Remove wrong comments, improve others.
1 parent 80d2c49 commit 9b1eaf6

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Python/ceval_gil.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,7 @@ drop_gil(PyInterpreterState *interp, PyThreadState *tstate, int final_release)
279279
280280
The function saves errno at entry and restores its value at exit.
281281
282-
tstate must be non-NULL.
283-
284-
Returns 1 if the GIL was acquired, or 0 if not. */
282+
tstate must be non-NULL. */
285283
static void
286284
take_gil(PyThreadState *tstate)
287285
{
@@ -294,11 +292,17 @@ take_gil(PyThreadState *tstate)
294292

295293
if (_PyThreadState_MustExit(tstate)) {
296294
/* bpo-39877: If Py_Finalize() has been called and tstate is not the
297-
thread which called Py_Finalize(), exit immediately the thread.
295+
thread which called Py_Finalize(), this thread cannot continue.
298296
299297
This code path can be reached by a daemon thread after Py_Finalize()
300298
completes. In this case, tstate is a dangling pointer: points to
301-
PyThreadState freed memory. */
299+
PyThreadState freed memory.
300+
301+
This used to call a *thread_exit API, but that was not safe as it
302+
lacks stack unwinding and local variable destruction important to
303+
C++. gh-87135: The best that can be done is to hang the thread as
304+
the public APIs calling this have no error reporting mechanism (!).
305+
*/
302306
PyThread_hang_thread();
303307
}
304308

0 commit comments

Comments
 (0)