Closed colesbury closed 1 year ago
More recent changes (not all need to be rebased):
Deferred tasks:
_mi_page_use_qsbr
on Windows (move to _PyMem ?)Dictionary TODOs:
dk_version
/ next_keys_version
(dict keys version)dk_mutex
lock should not detach thread when it blocks (otherwise dictionary might change underneath us).registry = list(_finalizer_registry)
TSAN races to fix:
keys->dk_usable
in init_inline_values
with non-atomic read in insert_into_dictkeys
self->locked
). sem_clockwait
is not instrumented (I think). Is it still being called under TSAN?PyMem_RawFree(interp)
vs. _PyEval_ReleaseLock
(tstate->interp->runtime->ceval
) called from _PyThreadState_DeleteCurrent
. (Fix todo: check gil->enabled before dereferencing tstate->interp
)use_tracing
(via PyEval_SetProfileAllThreads and _PyEval_SetProfile): https://github.com/colesbury/nogil-3.12/blob/78050fa422e93d3eb90d7be00a7600d08381d889/Include/internal/pycore_pystate.h#L206 and https://github.com/colesbury/nogil-3.12/blob/78050fa422e93d3eb90d7be00a7600d08381d889/Python/generated_cases.c.h#L714 (Stop the world? Or concurrently enable tracing?)_PyRuntime.stop_the_world
(Should it be set after the world is stopped or at request?) https://github.com/colesbury/nogil-3.12/blob/78050fa422e93d3eb90d7be00a7600d08381d889/Python/pystate.c#L317 and https://github.com/colesbury/nogil-3.12/blob/78050fa422e93d3eb90d7be00a7600d08381d889/Objects/object.c#L2601free_threadstate
e.g. https://github.com/colesbury/nogil-3.12/blob/78050fa422e93d3eb90d7be00a7600d08381d889/Python/pystate.c#L984 and https://github.com/colesbury/nogil-3.12/blob/78050fa422e93d3eb90d7be00a7600d08381d889/Python/ceval_gil.c#L228 (GIL is re-enabled in subtest, but problem exists generally because main thread deletes thread states while those threads are still running. Now that eval_breaker is in threadstate, this is problematic. Maybe refcount thread states is easiest fix.)threading.Lock()
(i.e., _thread.LockType
) supports acquiring/releasing from different threads. Not currently thread-safe without the GIL from different threads.Remaining nogil bugs:
python: Python/generated_cases.c.h:1336: _PyEval_EvalFrameDefault: Assertion `cframe.use_tracing == 0' failed.
Fatal Python error: Aborted
Stack (most recent call first): File "/raid/sgross/nogil/Lib/threading.py", line 329 in wait File "/raid/sgross/nogil/Lib/threading.py", line 636 in wait File "/raid/sgross/nogil/Lib/test/test_import/init.py", line 462 in run File "/raid/sgross/nogil/Lib/threading.py", line 965 in run File "/raid/sgross/nogil/Lib/threading.py", line 1014 in _bootstrap_inner File "/raid/sgross/nogil/Lib/threading.py", line 985 in _bootstrap
- [x] test_sys (test_current_exceptions)
Warning -- threading_cleanup() failed to cleanup 1 threads (count: 1, dangling: 2) Warning -- Dangling thread: <Thread(Thread-1 (f123), started 139718199457536)> Warning -- Dangling thread: <_MainThread(MainThread, started 139718204011136)> Warning -- threading._dangling was modified by test_sys Warning -- Before: {<weakref at 0x4804cf0a460; to '_MainThread' at 0x4804c383be0>} Warning -- After: {<weakref at 0x4804cf08f60; to 'Thread' at 0x4804d1c0a20>, <weakref at 0x4804cf0bff0; to '_MainThread' at 0x4804c383be0>} test test_sys failed -- Traceback (most recent call last): File "/raid/sgross/nogil/Lib/test/support/threading_helper.py", line 63, in decorator return func(*args) ^^^^^^^^^^^ File "/raid/sgross/nogil/Lib/test/test_sys.py", line 520, in test_current_exceptions stack = traceback.extract_stack(exc_tb.tb_frame) ^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'tb_frame'
{"name": "test_sys", "duration_sec": 4.2834788602776825, "xml_data": null, "errors": [["test_current_exceptions (test.test_sys.SysModuleTest.test_current_exceptions)", "Traceback (most recent call last):\ n File \"/raid/sgross/nogil/Lib/test/support/threading_helper.py\", line 63, in decorator\n return func(*args)\n ^^^^^^^^^^^\n File \"/raid/sgross/nogil/Lib/test/test_sys.py\", line 520, in test_current_exceptions\n stack = traceback.extract_stack(exc_tb.tb_frame)\n ^^^^^^^^^^^^^^^\nAttributeError: 'NoneType' object has no attribute 'tb_frame'\n"]], "fa ilures": [], "__test_result__": "Failed"} Timeout (0:02:00)! Thread 0x00007f12ada5b700 (most recent call first): File "/raid/sgross/nogil/Lib/threading.py", line 340 in wait File "/raid/sgross/nogil/Lib/threading.py", line 636 in wait File "/raid/sgross/nogil/Lib/test/test_sys.py", line 493 in g456 File "/raid/sgross/nogil/Lib/test/test_sys.py", line 484 in f123 File "/raid/sgross/nogil/Lib/threading.py", line 965 in run File "/raid/sgross/nogil/Lib/threading.py", line 1014 in _bootstrap_inner File "/raid/sgross/nogil/Lib/threading.py", line 985 in _bootstrap
Thread 0x00007f12adeb3280 (most recent call first): File "/raid/sgross/nogil/Lib/threading.py", line 1478 in _shutdown
c734997c4b Implement new interpreter36d9f3c9aa test_gdb: nogil mode fixes4bcc712534 frame: don't use zombieframe when running without the GILd3503e92a4 accu: don't acquire list lock when appending87364a937a typeobject: remove static cache in resolve_slotdupscbbf4d38c0 Disable most free lists9c5049d351 Call function when incref/decrefc40dda7f82 Add ob_tid to every object