summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-03-16 22:25:02 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-03-16 22:25:02 (GMT)
commit13be7db34c698010d2a10e7ebbb1503f3495b20c (patch)
treee6acfdd2c615a6c145ebb45bd0b07d27cbca8491 /Modules
parent2025d7839b1d0c5c3cc83601568f16177b1d85b0 (diff)
downloadcpython-13be7db34c698010d2a10e7ebbb1503f3495b20c.zip
cpython-13be7db34c698010d2a10e7ebbb1503f3495b20c.tar.gz
cpython-13be7db34c698010d2a10e7ebbb1503f3495b20c.tar.bz2
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.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/overlapped.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Modules/overlapped.c b/Modules/overlapped.c
index ef77c88..8e6d397 100644
--- a/Modules/overlapped.c
+++ b/Modules/overlapped.c
@@ -238,7 +238,7 @@ PostToQueueCallback(PVOID lpParameter, BOOL TimerOrWaitFired)
PostQueuedCompletionStatus(p->CompletionPort, TimerOrWaitFired,
0, p->Overlapped);
/* ignore possible error! */
- PyMem_Free(p);
+ PyMem_RawFree(p);
}
PyDoc_STRVAR(
@@ -262,7 +262,10 @@ overlapped_RegisterWaitWithQueue(PyObject *self, PyObject *args)
&Milliseconds))
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)
return SetFromWindowsErr(0);
@@ -273,7 +276,7 @@ overlapped_RegisterWaitWithQueue(PyObject *self, PyObject *args)
pdata, Milliseconds,
WT_EXECUTEINWAITTHREAD | WT_EXECUTEONLYONCE))
{
- PyMem_Free(pdata);
+ PyMem_RawFree(pdata);
return SetFromWindowsErr(0);
}