Repository navigation
Commit 27dcd28
committed
Fix asyncio loop lookup on Python 3.14.0–3.14.3 (#515)
Python 3.14.4 appended `datastack_cached_chunk` to the public `PyThreadState` struct (python/cpython@19cbcc0f85, gh-142183), making `sizeof(PyThreadState)` 8 bytes larger. `_PyThreadStateImpl` embeds `PyThreadState` by value, so every private field after it, including `asyncio_running_loop`, shifted by 8 bytes.
The offset was fixed at compile time by the headers the wheel was built against. A wheel built with 3.14.4+ headers and run on 3.14.0–3.14.3 read `asyncio_running_task` instead, which treated the running Task as the event loop and crashed on any `await` of a JS promise. A wheel built with older headers and run on 3.14.4+ read `c_stack_hard_limit` and crashed the same way.
On Python 3.14, compare the runtime `Py_Version` with the compile-time `PY_VERSION_HEX`, and move the offset by one pointer when they fall on different sides of 3.14.4.1 parent 8789e60 commit 27dcd28
1 file changed
Lines changed: 21 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
205 | 206 | | |
206 | 207 | | |
207 | 208 | | |
208 | | - | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
209 | 229 | | |
210 | 230 | | |
211 | 231 | | |
| |||
0 commit comments