Repository navigation
Commit 0279ee2
committed
gh-159244: Fix crash in dict() on a concurrently mutated key/value pair
In the free-threaded build, dict() and dict.update() checked that a
list key/value pair had two items and then read them with borrowed
references without holding its lock, so another thread could empty
the list in between and the items were read from a freed or NULL
array.
Read the size and both items under
Py_BEGIN_CRITICAL_SECTION_SEQUENCE_FAST, as bytes.join() and
str.join() already do.1 parent 0babcdd commit 0279ee2
3 files changed
Lines changed: 34 additions & 6 deletions
File tree
- Lib/test/test_free_threading
- Misc/NEWS.d/next/Core_and_Builtins
- Objects
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
359 | 382 | | |
360 | 383 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4115 | 4115 | | |
4116 | 4116 | | |
4117 | 4117 | | |
4118 | | - | |
| 4118 | + | |
4119 | 4119 | | |
4120 | 4120 | | |
4121 | 4121 | | |
| |||
4137 | 4137 | | |
4138 | 4138 | | |
4139 | 4139 | | |
| 4140 | + | |
4140 | 4141 | | |
| 4142 | + | |
| 4143 | + | |
| 4144 | + | |
| 4145 | + | |
| 4146 | + | |
4141 | 4147 | | |
4142 | 4148 | | |
4143 | 4149 | | |
| |||
4147 | 4153 | | |
4148 | 4154 | | |
4149 | 4155 | | |
4150 | | - | |
4151 | | - | |
4152 | | - | |
4153 | | - | |
4154 | 4156 | | |
4155 | 4157 | | |
4156 | 4158 | | |
| |||
0 commit comments