-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test_interpreters: when TestInterpreterAttrs.test_id_type() is run alone, it fails with an assertion error #88128
Comments
Example on Linux. $ ./python -m test test_interpreters -m test.test_interpreters.TestInterpreterAttrs.test_id_type
0:00:00 load avg: 1.20 Run tests sequentially
0:00:00 load avg: 1.20 [1/1] test_interpreters
python: Python/pystate.c:561: _PyInterpreterState_IDDecref: Assertion `interp->id_refcount != 0' failed.
Fatal Python error: Aborted Current thread 0x00007f05eab42740 (most recent call first): Extension modules: _testcapi, _xxsubinterpreters (total: 2) When the whole test case is run, it's fine: $ ./python -m test test_interpreters -m TestInterpreterAttrs -v
== CPython 3.10.0a7+ (heads/master:6bd9288b80, Apr 27 2021, 22:16:25) [GCC 11.0.1 20210324 (Red Hat 11.0.1-0)]
== Linux-5.11.15-300.fc34.x86_64-x86_64-with-glibc2.33 little-endian
== cwd: /home/vstinner/python/master/build/test_python_16394æ
== CPU count: 8
== encodings: locale=UTF-8, FS=utf-8
0:00:00 load avg: 1.39 Run tests sequentially
0:00:00 load avg: 1.39 [1/1] test_interpreters
test_custom_id (test.test_interpreters.TestInterpreterAttrs) ... ok
test_custom_isolated_default (test.test_interpreters.TestInterpreterAttrs) ... skipped 'not ready yet (see bpo-32604)'
test_custom_isolated_explicit (test.test_interpreters.TestInterpreterAttrs) ... ok
test_equality (test.test_interpreters.TestInterpreterAttrs) ... ok
test_id_readonly (test.test_interpreters.TestInterpreterAttrs) ... ok
test_id_type (test.test_interpreters.TestInterpreterAttrs) ... ok
test_isolated_readonly (test.test_interpreters.TestInterpreterAttrs) ... ok
test_main_id (test.test_interpreters.TestInterpreterAttrs) ... ok
test_main_isolated (test.test_interpreters.TestInterpreterAttrs) ... skipped 'not ready yet (see bpo-32604)'
test_subinterpreter_isolated_default (test.test_interpreters.TestInterpreterAttrs) ... skipped 'not ready yet (see bpo-32604)'
test_subinterpreter_isolated_explicit (test.test_interpreters.TestInterpreterAttrs) ... ok Ran 11 tests in 0.159s OK (skipped=3) == Tests result: SUCCESS == 1 test OK. Total duration: 285 ms |
Creating an _interpreters.InterpreterID object calls newinterpid() which calls _PyInterpreterState_IDIncref(interp). _PyInterpreterState_IDIncref(interp) does nothing if interp->id_mutex is NULL. Calling _interpreters.get_current() calls interp_get_current() which calls _PyInterpreterState_IDInitref(). _PyInterpreterState_IDInitref() creates the id_mutex and initializes id_refcount to 0. Later, when the _interpreters.InterpreterID object is deallocated, interpid_dealloc() calls _PyInterpreterState_IDDecref(). Since id_mutex was created in the meanwhile, _PyInterpreterState_IDDecref() now decrements id_refcnt. ... It doesn't work: _PyInterpreterState_IDIncref() should always increase the reference count. |
Closing as it seems fixed. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: