You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test_interpreters: when TestInterpreterAttrs.test_id_type() is run alone, it fails with an assertion error #88128
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:
assignee=Noneclosed_at=Nonecreated_at=<Date2021-04-27.22:55:01.625>labels= ['tests', '3.10']
title='test_interpreters: when TestInterpreterAttrs.test_id_type() is run alone, it fails with an assertion error'updated_at=<Date2021-04-28.13:47:01.117>user='https://github.com/vstinner'
Current thread 0x00007f05eab42740 (most recent call first):
File "/home/vstinner/python/master/Lib/unittest/case.py", line 549 in _callTestMethod
File "/home/vstinner/python/master/Lib/unittest/case.py", line 592 in run
File "/home/vstinner/python/master/Lib/unittest/case.py", line 652 in __call__
File "/home/vstinner/python/master/Lib/unittest/suite.py", line 122 in run
File "/home/vstinner/python/master/Lib/unittest/suite.py", line 84 in __call__
File "/home/vstinner/python/master/Lib/unittest/suite.py", line 122 in run
File "/home/vstinner/python/master/Lib/unittest/suite.py", line 84 in __call__
File "/home/vstinner/python/master/Lib/unittest/suite.py", line 122 in run
File "/home/vstinner/python/master/Lib/unittest/suite.py", line 84 in __call__
File "/home/vstinner/python/master/Lib/test/support/testresult.py", line 169 in run
File "/home/vstinner/python/master/Lib/test/support/init.py", line 959 in _run_suite
File "/home/vstinner/python/master/Lib/test/support/init.py", line 1082 in run_unittest
File "/home/vstinner/python/master/Lib/test/libregrtest/runtest.py", line 210 in _test_module
File "/home/vstinner/python/master/Lib/test/libregrtest/runtest.py", line 246 in _runtest_inner2
File "/home/vstinner/python/master/Lib/test/libregrtest/runtest.py", line 282 in _runtest_inner
File "/home/vstinner/python/master/Lib/test/libregrtest/runtest.py", line 154 in _runtest
File "/home/vstinner/python/master/Lib/test/libregrtest/runtest.py", line 194 in runtest
File "/home/vstinner/python/master/Lib/test/libregrtest/main.py", line 423 in run_tests_sequential
File "/home/vstinner/python/master/Lib/test/libregrtest/main.py", line 521 in run_tests
File "/home/vstinner/python/master/Lib/test/libregrtest/main.py", line 694 in _main
File "/home/vstinner/python/master/Lib/test/libregrtest/main.py", line 641 in main
File "/home/vstinner/python/master/Lib/test/libregrtest/main.py", line 719 in main
File "/home/vstinner/python/master/Lib/test/main.py", line 2 in <module>
File "/home/vstinner/python/master/Lib/runpy.py", line 86 in _run_code
File "/home/vstinner/python/master/Lib/runpy.py", line 196 in _run_module_as_main
changed the title [-]test_interpreters: when test_id_type() is run alone, it fails with an assertion error[/-][+]test_interpreters: when TestInterpreterAttrs.test_id_type() is run alone, it fails with an assertion error[/+]on Apr 27, 2021
changed the title [-]test_interpreters: when test_id_type() is run alone, it fails with an assertion error[/-][+]test_interpreters: when TestInterpreterAttrs.test_id_type() is run alone, it fails with an assertion error[/+]on Apr 27, 2021
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.
Activity
vstinner commentedon Apr 27, 2021
Example on Linux.
Current thread 0x00007f05eab42740 (most recent call first):
File "/home/vstinner/python/master/Lib/unittest/case.py", line 549 in _callTestMethod
File "/home/vstinner/python/master/Lib/unittest/case.py", line 592 in run
File "/home/vstinner/python/master/Lib/unittest/case.py", line 652 in __call__
File "/home/vstinner/python/master/Lib/unittest/suite.py", line 122 in run
File "/home/vstinner/python/master/Lib/unittest/suite.py", line 84 in __call__
File "/home/vstinner/python/master/Lib/unittest/suite.py", line 122 in run
File "/home/vstinner/python/master/Lib/unittest/suite.py", line 84 in __call__
File "/home/vstinner/python/master/Lib/unittest/suite.py", line 122 in run
File "/home/vstinner/python/master/Lib/unittest/suite.py", line 84 in __call__
File "/home/vstinner/python/master/Lib/test/support/testresult.py", line 169 in run
File "/home/vstinner/python/master/Lib/test/support/init.py", line 959 in _run_suite
File "/home/vstinner/python/master/Lib/test/support/init.py", line 1082 in run_unittest
File "/home/vstinner/python/master/Lib/test/libregrtest/runtest.py", line 210 in _test_module
File "/home/vstinner/python/master/Lib/test/libregrtest/runtest.py", line 246 in _runtest_inner2
File "/home/vstinner/python/master/Lib/test/libregrtest/runtest.py", line 282 in _runtest_inner
File "/home/vstinner/python/master/Lib/test/libregrtest/runtest.py", line 154 in _runtest
File "/home/vstinner/python/master/Lib/test/libregrtest/runtest.py", line 194 in runtest
File "/home/vstinner/python/master/Lib/test/libregrtest/main.py", line 423 in run_tests_sequential
File "/home/vstinner/python/master/Lib/test/libregrtest/main.py", line 521 in run_tests
File "/home/vstinner/python/master/Lib/test/libregrtest/main.py", line 694 in _main
File "/home/vstinner/python/master/Lib/test/libregrtest/main.py", line 641 in main
File "/home/vstinner/python/master/Lib/test/libregrtest/main.py", line 719 in main
File "/home/vstinner/python/master/Lib/test/main.py", line 2 in <module>
File "/home/vstinner/python/master/Lib/runpy.py", line 86 in _run_code
File "/home/vstinner/python/master/Lib/runpy.py", line 196 in _run_module_as_main
Extension modules: _testcapi, _xxsubinterpreters (total: 2)
Abandon (core dumped)
When the whole test case is run, it's fine:
Ran 11 tests in 0.159s
OK (skipped=3)
== Tests result: SUCCESS ==
1 test OK.
Total duration: 285 ms
Tests result: SUCCESS
[-]test_interpreters: when test_id_type() is run alone, it fails with an assertion error[/-][+]test_interpreters: when TestInterpreterAttrs.test_id_type() is run alone, it fails with an assertion error[/+][-]test_interpreters: when test_id_type() is run alone, it fails with an assertion error[/-][+]test_interpreters: when TestInterpreterAttrs.test_id_type() is run alone, it fails with an assertion error[/+]vstinner commentedon Apr 28, 2021
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.
vstinner commentedon Apr 28, 2021
New changeset 32c5a17 by Victor Stinner in branch 'master':
bpo-43962: Fix _PyInterpreterState_IDIncref() (GH-25683)
32c5a17
vstinner commentedon Apr 28, 2021
New changeset 77db337 by Victor Stinner in branch '3.8':
bpo-43962: Fix _PyInterpreterState_IDIncref() (GH-25683) (GH-25686)
77db337
kumaraditya303 commentedon May 22, 2022
Closing as it seems fixed.