bpo-33015: Use malloc() in PyThread_start_new_thread() (GH-10829)
https://github.com/python/cpython/commit/bc9f53f69e8207027bf2b18e3d01b30401e... commit: bc9f53f69e8207027bf2b18e3d01b30401e76ace branch: 2.7 author: Victor Stinner <vstinner@redhat.com> committer: GitHub <noreply@github.com> date: 2018-11-30T18:08:02+01:00 summary: bpo-33015: Use malloc() in PyThread_start_new_thread() (GH-10829) The pthread implementation of PyThread_start_new_thread() now uses malloc/free rather than PyMem_Malloc/PyMem_Free, since the latters are not thread-safe. files: M Python/thread_pthread.h diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h index ae6b6b683904..6d4b3b389f82 100644 --- a/Python/thread_pthread.h +++ b/Python/thread_pthread.h @@ -173,7 +173,7 @@ pythread_wrapper(void *arg) pythread_callback *callback = arg; void (*func)(void *) = callback->func; void *func_arg = callback->arg; - PyMem_Free(arg); + free(arg); func(func_arg); return NULL; @@ -213,7 +213,7 @@ PyThread_start_new_thread(void (*func)(void *), void *arg) pthread_attr_setscope(&attrs, PTHREAD_SCOPE_SYSTEM); #endif - pythread_callback *callback = PyMem_Malloc(sizeof(pythread_callback)); + pythread_callback *callback = malloc(sizeof(pythread_callback)); if (callback == NULL) { return -1; @@ -235,7 +235,7 @@ PyThread_start_new_thread(void (*func)(void *), void *arg) #endif if (status != 0) { - PyMem_Free(callback); + free(callback); return -1; }
participants (1)
-
Victor Stinner