Skip to content

Fix hashtable insertion race. (Free-Threaded) - #1327

Closed
Vizonex wants to merge 8 commits into
aio-libs:masterfrom
Vizonex:critical-sections
Closed

Vizonex wants to merge 8 commits into
aio-libs:masterfrom
Vizonex:critical-sections

Conversation

@Vizonex

@Vizonex Vizonex commented Apr 28, 2026

Copy link
Copy Markdown
Member

What do these changes do?

This change comes related to _md_add_with_hash_steal_refs Which mentions a possible hashtable insertion race in free-threaded mode.

Are there changes in behavior for the user?

this should not affect the pure python version of multidict only the C version.

Related issue number

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes

@Vizonex
Vizonex requested a review from asvetlov as a code owner April 28, 2026 19:50
@Vizonex
Vizonex requested a review from webknjaz as a code owner April 28, 2026 19:51
@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided There is a change note present in this PR label Apr 28, 2026
@codspeed

codspeed Bot commented Apr 28, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 242 untouched benchmarks


Comparing Vizonex:critical-sections (8a4e540) with master (41c1b91)

Open in CodSpeed

@Vizonex

Vizonex commented Apr 28, 2026

Copy link
Copy Markdown
Member Author

Would be nice if we made a label for free-threaded pull requests but I don't know if that will be necessary yet.

@Vizonex

Vizonex commented Apr 28, 2026

Copy link
Copy Markdown
Member Author

3.13t plans to be removed by #1326 so I'm not so concerned if 3.13t fails.

@Vizonex Vizonex mentioned this pull request Apr 28, 2026
3 tasks done
@webknjaz webknjaz added the free-threading FT-related discussion, issue or PR label Apr 29, 2026
@webknjaz

Copy link
Copy Markdown
Member

Labels are cheap, I've added one.

Comment thread CHANGES/1327.bugfix.rst Resolved
import sysconfig
import textwrap

FREETHREADED = bool(sysconfig.get_config_var("Py_GIL_DISABLED"))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced we should gate on this here.

cc @Dreamsorcerer

Vizonex and others added 2 commits April 29, 2026 10:02
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.86%. Comparing base (eece5fb) to head (a6b4a10).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1327   +/-   ##
=======================================
  Coverage   99.86%   99.86%           
=======================================
  Files          28       29    +1     
  Lines        3627     3636    +9     
  Branches      265      266    +1     
=======================================
+ Hits         3622     3631    +9     
  Misses          3        3           
  Partials        2        2           
Flag Coverage Δ
CI-GHA 99.86% <100.00%> (+<0.01%) ⬆️
pytest 99.86% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@asvetlov

Copy link
Copy Markdown
Member

I guess it is done by recent PRs that fix the free-threading mode.
Any multidict modification is now protected by critical sections.

@asvetlov asvetlov closed this Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided There is a change note present in this PR free-threading FT-related discussion, issue or PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants