Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Remove calls of :c:func:`PyThread_exit_thread()` from top-level thread
functions, thereby avoiding a runtime dependency on ``libgcc_s.so`` and
associated issues with lazy-loading it via ``dlopen()`` in typical scenarios
on glibc-based Linux systems.
2 changes: 0 additions & 2 deletions Modules/_testcapimodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4512,8 +4512,6 @@ temporary_c_thread(void *data)
PyGILState_Release(state);

PyThread_release_lock(test_c_thread->exit_event);

PyThread_exit_thread();
}

static PyObject *
Expand Down
2 changes: 0 additions & 2 deletions Modules/_threadmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1087,8 +1087,6 @@ thread_run(void *boot_raw)
tstate->interp->num_threads--;
PyThreadState_Clear(tstate);
_PyThreadState_DeleteCurrent(tstate);

PyThread_exit_thread();
}

static PyObject *
Expand Down
2 changes: 0 additions & 2 deletions Programs/_testembed.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,6 @@ static void bpo20891_thread(void *lockp)
PyGILState_Release(state);

PyThread_release_lock(lock);

PyThread_exit_thread();
}

static int test_bpo20891(void)
Expand Down
10 changes: 9 additions & 1 deletion Python/thread_nt.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ PyThread__init_thread(void)
* Thread support.
*/

static void
_pythread_at_thread_exit(void)
{
dprintf(("%lu: _pythread_at_thread_exit called\n",
PyThread_get_thread_ident()));
}

typedef struct {
void (*func)(void*);
void *arg;
Expand All @@ -175,6 +182,7 @@ bootstrap(void *call)
void *arg = obj->arg;
HeapFree(GetProcessHeap(), 0, obj);
func(arg);
_pythread_at_thread_exit();
return 0;
}

Expand Down Expand Up @@ -254,7 +262,7 @@ PyThread_get_thread_native_id(void)
void _Py_NO_RETURN
PyThread_exit_thread(void)
{
dprintf(("%lu: PyThread_exit_thread called\n", PyThread_get_thread_ident()));
_pythread_at_thread_exit();
if (!initialized)
exit(0);
_endthreadex(0);
Expand Down
9 changes: 8 additions & 1 deletion Python/thread_pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ PyThread__init_thread(void)
* Thread support.
*/

static void
_pythread_at_thread_exit(void)
{
dprintf(("_pythread_at_thread_exit called\n"));
}

/* bpo-33015: pythread_callback struct and pythread_wrapper() cast
"void func(void *)" to "void* func(void *)": always return NULL.

Expand All @@ -238,6 +244,7 @@ pythread_wrapper(void *arg)
PyMem_RawFree(arg);

func(func_arg);
_pythread_at_thread_exit();
return NULL;
}

Expand Down Expand Up @@ -359,7 +366,7 @@ PyThread_get_thread_native_id(void)
void _Py_NO_RETURN
PyThread_exit_thread(void)
{
dprintf(("PyThread_exit_thread called\n"));
_pythread_at_thread_exit();
if (!initialized)
exit(0);
pthread_exit(0);
Expand Down