• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

aio-libs / multidict / 35761211686
87%

Build:
DEFAULT BRANCH: master
Ran 22 Sep 2026 05:31PM UTC
Jobs 1
Files 40
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

22 Sep 2026 05:30PM UTC coverage: 87.778% (+0.03%) from 87.749%
35761211686

push

github

web-flow
Fix a data race on the MultiDict version counter (#1514)

<!-- Thank you for your contribution! -->

## What do these changes do?

`md_version()` read `md->version` with a plain, non-atomic load, while
every mutation site wrote it with a plain store under the object's own
critical section. On a free-threaded build, `getversion()` (which calls
`md_version()` without taking that critical section) could race a
concurrent writer. Both sides now use the relaxed atomic load/store pair
already used for the object's item count, so the read and every write
site go through `atomic_load_uint64_relaxed()` /
`atomic_store_uint64_relaxed()`.

## Are there changes in behavior for the user?

No. `getversion()` still returns the same opaque, per-mutation token;
this only removes a data race on free-threaded builds.

## Is it a substantial burden for the maintainers to support this?

No, it mirrors the existing atomic-op pattern in `atomic_helpers.h`.

## Related issue number

Related to #1444, which fixed the analogous race on the shared global
counter but left the per-object `md->version` field itself unaddressed.

## Checklist

- [x] I think the code is well written
- [x] Unit tests for the changes exist
- [x] Documentation reflects the changes
- [ ] If you provide code modification, please add yourself to
`CONTRIBUTORS.txt`
- [x] Add a new news fragment into the `CHANGES/` folder
- [x] `make doc-spelling` passes and any new technical words are added
to `docs/spelling_wordlist.txt`

Drafted with Claude Code (Sonnet 5); reviewed by asvetlov.

<details>
<summary>Agent run details (optional, for reviewers)</summary>

Tests: `pytest -q`, all green on the C extension under a normal GIL
build (2160 passed), a free-threaded 3.14t build (2148 passed), and the
pure-Python build (2160 passed, unchanged since this is C-extension
only).
New test:
`tests/test_free_threading.py::test_race_condition_getversion_vs_mutation`,
marked `c_extension`.
Sanitizer: confirmed with `MULTIDIC... (continued)

765 of 1530 branches covered (50.0%)

Branch coverage included in aggregate %.

41 of 41 new or added lines in 1 file covered. (100.0%)

6769 of 7053 relevant lines covered (95.97%)

1.92 hits per line

Jobs
ID Job ID Ran Files Coverage
1 MyPy - 35761211686.1 22 Sep 2026 05:31PM UTC 80
87.78
GitHub Action Run
Source Files on build 35761211686
  • Tree
  • List 40
  • Changed 3
  • Source Changed 1
  • Coverage Changed 3
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #35761211686
  • e1f32927 on github
  • Prev Build on master (#35707035635)
  • Next Build on master (#35772873630)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc