diff options
| author | Brett Simmers <swtaarrs@users.noreply.github.com> | 2024-03-20 15:18:26 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-20 15:18:26 (GMT) |
| commit | 9221ef2d8cb7f4cf37592eb650d4c8f972033000 (patch) | |
| tree | 9f4e40bfc4868b7f75637fcda7b3cf5a9f3db3d6 /Python/ceval_gil.c | |
| parent | fc4599800778f9b130d5e336deadbdeb5bd3e5ee (diff) | |
| download | cpython-9221ef2d8cb7f4cf37592eb650d4c8f972033000.zip cpython-9221ef2d8cb7f4cf37592eb650d4c8f972033000.tar.gz cpython-9221ef2d8cb7f4cf37592eb650d4c8f972033000.tar.bz2 | |
gh-116908: Only write to `_pending_calls.calls_to_do` with atomic operations (#117044)
These writes to `pending->calls_to_do` need to be atomic, because other threads
can read (atomically) from `calls_to_do` without holding `pending->mutex`.
Diffstat (limited to 'Python/ceval_gil.c')
| -rw-r--r-- | Python/ceval_gil.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Python/ceval_gil.c b/Python/ceval_gil.c index d2cd35d..78c13d6 100644 --- a/Python/ceval_gil.c +++ b/Python/ceval_gil.c @@ -671,7 +671,7 @@ _push_pending_call(struct _pending_calls *pending, pending->calls[i].flags = flags; pending->last = j; assert(pending->calls_to_do < NPENDINGCALLS); - pending->calls_to_do++; + _Py_atomic_add_int32(&pending->calls_to_do, 1); return 0; } @@ -701,7 +701,7 @@ _pop_pending_call(struct _pending_calls *pending, pending->calls[i] = (struct _pending_call){0}; pending->first = (i + 1) % NPENDINGCALLS; assert(pending->calls_to_do > 0); - pending->calls_to_do--; + _Py_atomic_add_int32(&pending->calls_to_do, -1); } } |
