Skip to content

Commit 6afec34

Browse files
committed
protect ob_exports exclusively with critical section
1 parent 0532d93 commit 6afec34

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

Modules/arraymodule.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2842,11 +2842,7 @@ array_buffer_getbuf_lock_held(arrayobject *self, Py_buffer *view, int flags)
28422842
#endif
28432843
}
28442844

2845-
#ifdef Py_GIL_DISABLED
2846-
_Py_atomic_add_ssize(&self->ob_exports, 1);
2847-
#else
28482845
self->ob_exports++;
2849-
#endif
28502846
return 0;
28512847
}
28522848

@@ -2863,12 +2859,10 @@ array_buffer_getbuf(arrayobject *self, Py_buffer *view, int flags)
28632859
static void
28642860
array_buffer_relbuf(arrayobject *self, Py_buffer *view)
28652861
{
2866-
#ifdef Py_GIL_DISABLED
2867-
assert(_Py_atomic_add_ssize(&self->ob_exports, -1) >= 1);
2868-
#else
2862+
Py_BEGIN_CRITICAL_SECTION(self);
28692863
self->ob_exports--;
28702864
assert(self->ob_exports >= 0);
2871-
#endif
2865+
Py_END_CRITICAL_SECTION();
28722866
}
28732867

28742868
static PyObject *

0 commit comments

Comments
 (0)