mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Fix usage of PyMem_Malloc() in overlapped.c
Issue #26563: Replace PyMem_Malloc() with PyMem_RawFree() since PostToQueueCallback() calls PyMem_RawFree() (previously PyMem_Free()) in a new C thread which doesn't hold the GIL.
This commit is contained in:
parent
2025d7839b
commit
13be7db34c
1 changed files with 6 additions and 3 deletions
|
@ -238,7 +238,7 @@ PostToQueueCallback(PVOID lpParameter, BOOL TimerOrWaitFired)
|
||||||
PostQueuedCompletionStatus(p->CompletionPort, TimerOrWaitFired,
|
PostQueuedCompletionStatus(p->CompletionPort, TimerOrWaitFired,
|
||||||
0, p->Overlapped);
|
0, p->Overlapped);
|
||||||
/* ignore possible error! */
|
/* ignore possible error! */
|
||||||
PyMem_Free(p);
|
PyMem_RawFree(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(
|
PyDoc_STRVAR(
|
||||||
|
@ -262,7 +262,10 @@ overlapped_RegisterWaitWithQueue(PyObject *self, PyObject *args)
|
||||||
&Milliseconds))
|
&Milliseconds))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
pdata = PyMem_Malloc(sizeof(struct PostCallbackData));
|
/* Use PyMem_RawMalloc() rather than PyMem_Malloc(), since
|
||||||
|
PostToQueueCallback() will call PyMem_Free() from a new C thread
|
||||||
|
which doesn't hold the GIL. */
|
||||||
|
pdata = PyMem_RawMalloc(sizeof(struct PostCallbackData));
|
||||||
if (pdata == NULL)
|
if (pdata == NULL)
|
||||||
return SetFromWindowsErr(0);
|
return SetFromWindowsErr(0);
|
||||||
|
|
||||||
|
@ -273,7 +276,7 @@ overlapped_RegisterWaitWithQueue(PyObject *self, PyObject *args)
|
||||||
pdata, Milliseconds,
|
pdata, Milliseconds,
|
||||||
WT_EXECUTEINWAITTHREAD | WT_EXECUTEONLYONCE))
|
WT_EXECUTEINWAITTHREAD | WT_EXECUTEONLYONCE))
|
||||||
{
|
{
|
||||||
PyMem_Free(pdata);
|
PyMem_RawFree(pdata);
|
||||||
return SetFromWindowsErr(0);
|
return SetFromWindowsErr(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue