Skip to content

Commit 89e4127

Browse files
kumaraditya303seehwan80
authored andcommitted
pythongh-127945: acquire critical section around PyCFuncPtr_call (python#131898)
1 parent 9f3ebfd commit 89e4127

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Modules/_ctypes/_ctypes.c

+11-1
Original file line numberDiff line numberDiff line change
@@ -4406,7 +4406,7 @@ _build_result(PyObject *result, PyObject *callargs,
44064406
}
44074407

44084408
static PyObject *
4409-
PyCFuncPtr_call(PyObject *op, PyObject *inargs, PyObject *kwds)
4409+
PyCFuncPtr_call_lock_held(PyObject *op, PyObject *inargs, PyObject *kwds)
44104410
{
44114411
PyObject *restype;
44124412
PyObject *converters;
@@ -4544,6 +4544,16 @@ PyCFuncPtr_call(PyObject *op, PyObject *inargs, PyObject *kwds)
45444544
outmask, inoutmask, numretvals);
45454545
}
45464546

4547+
static PyObject *
4548+
PyCFuncPtr_call(PyObject *op, PyObject *inargs, PyObject *kwds)
4549+
{
4550+
PyObject *result;
4551+
Py_BEGIN_CRITICAL_SECTION(op);
4552+
result = PyCFuncPtr_call_lock_held(op, inargs, kwds);
4553+
Py_END_CRITICAL_SECTION();
4554+
return result;
4555+
}
4556+
45474557
static int
45484558
PyCFuncPtr_traverse(PyObject *op, visitproc visit, void *arg)
45494559
{

0 commit comments

Comments
 (0)