Repository navigation
Commit 44d14a7
committed
Thread-safety prep for free-threading builds
Two narrow fixes to remove obvious data races that already exist on the
GIL build and become hot paths under Py_GIL_DISABLED:
- InternString: replace plain Dictionary<> with ConcurrentDictionary<>
for both _string2interns and _intern2strings. These are written from
startup but read from every attribute-lookup hot path, so any
concurrent shutdown/reinit could tear them.
- ClassDerived.GetModuleBuilder: add a lock around the
check-then-create on assemblyBuilders/moduleBuilders. The previous
ContainsKey-then-DefineDynamicAssembly pattern had a TOCTOU race that
could produce duplicate builders. Reset() also now locks for a clean
reinitialisation.
These are not sufficient for full free-threading support, but they
remove low-hanging concurrency hazards.1 parent dc69411 commit 44d14a7
2 files changed
Lines changed: 22 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | | - | |
12 | | - | |
| 12 | + | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
78 | | - | |
79 | | - | |
| 79 | + | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
45 | | - | |
46 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
47 | 51 | | |
48 | 52 | | |
49 | 53 | | |
| |||
657 | 661 | | |
658 | 662 | | |
659 | 663 | | |
660 | | - | |
661 | | - | |
662 | | - | |
663 | | - | |
664 | | - | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
| 664 | + | |
| 665 | + | |
669 | 666 | | |
670 | | - | |
671 | | - | |
672 | | - | |
673 | | - | |
674 | | - | |
675 | | - | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
676 | 671 | | |
677 | | - | |
678 | | - | |
| 672 | + | |
| 673 | + | |
679 | 674 | | |
680 | 675 | | |
681 | 676 | | |
682 | | - | |
683 | | - | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
684 | 680 | | |
685 | | - | |
686 | | - | |
687 | 681 | | |
688 | 682 | | |
689 | 683 | | |
| |||
0 commit comments