Commit 4c889e8
committed
fix LOAD_INDEX/STORE_INDEX to use _DK_INDICES_BASE for well-defined pointer arithmetic
The previous macros used negative indexing from the PyDictKeysObject pointer
(e.g. ((int8_t*)keys)[-1-idx]) to access the indices stored before the struct.
This is undefined behavior: the compiler sees keys as typed PyDictKeysObject*
and negative indices are formally out-of-bounds, allowing MSVC's release optimizer
to generate incorrect hash table lookups.
Fix by using _DK_INDICES_BASE(keys) (the actual malloc base) with positive forward
indexing, which is well-defined pointer arithmetic within the allocation.1 parent e9d9ec5 commit 4c889e8
1 file changed
+4
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
186 | | - | |
| 185 | + | |
| 186 | + | |
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
265 | | - | |
266 | | - | |
| 265 | + | |
| 266 | + | |
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
| |||
0 commit comments