Repository navigation
Commit a8e8473
gh-152107: Guard GC untrack on untracked dict iterator under OOM
dictiter_new() allocates di->di_result via _PyTuple_FromPairSteal() for
item iterators before calling _PyObject_GC_TRACK(di). When that
allocation fails (OOM), the error path runs Py_DECREF(di) on the
still-untracked iterator, and dictiter_dealloc() unconditionally called
_PyObject_GC_UNTRACK(di) -- which asserts the object is GC-tracked.
This aborts on a debug build (Objects/dictobject.c) and corrupts the GC
list (later segfault) on a release build. Guard the untrack with
_PyObject_GC_IS_TRACKED() so the never-tracked iterator is freed cleanly.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent a46db4f commit a8e8473
3 files changed
Lines changed: 35 additions & 3 deletions
File tree
- Lib/test
- Misc/NEWS.d/next/Core_and_Builtins
- Objects
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
119 | 143 | | |
120 | 144 | | |
121 | 145 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5539 | 5539 | | |
5540 | 5540 | | |
5541 | 5541 | | |
5542 | | - | |
5543 | | - | |
| 5542 | + | |
| 5543 | + | |
| 5544 | + | |
| 5545 | + | |
| 5546 | + | |
| 5547 | + | |
| 5548 | + | |
5544 | 5549 | | |
5545 | 5550 | | |
5546 | 5551 | | |
| |||
0 commit comments