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
Python 3.10: Under some trivial circunstances, GIL not released #88811
Comments
After #18334, a "while condition: pass" in a thread will preclude releasing the GIL, hanging the program with CPU at 100%. Trivial to reproduce: """ import threading
import time
def worker():
while cont:
pass
def main():
global cont
cont = True
t = threading.Thread(target=worker)
t.start()
time.sleep(1)
cont = False
t.join()
if __name__ == '__main__':
main()
""" |
#18334 assumes that since all loops will contain a backwards edge, checking for interrupts on JUMP_ABSOLUTE should be sufficient. However, #23743 changed the back edges in while statements. So 2 0 LOAD_GLOBAL 0 (cont) 3 >> 4 NOP 2 6 LOAD_GLOBAL 0 (cont) which has no CALL or JUMP_ABSOLUTE instructions. |
PR 27167 hangs or fails. in the refleak buildbots, so I am going to proceed to revert |
To reproduce the problem: $./python -m test test_threading -R : -v ... test_original_excepthook (test.test_threading.ExceptHookTests) ... ok (HANGS here or some time fails like in: ====================================================================== Traceback (most recent call last):
File "/home/buildbot/buildarea/pull_request.cstratak-RHEL7-ppc64le.refleak/build/Lib/test/support/threading_helper.py", line 62, in decorator
return func(*args)
^^^^^^^^^^^
File "/home/buildbot/buildarea/pull_request.cstratak-RHEL7-ppc64le.refleak/build/Lib/test/test_threading.py", line 1630, in test_can_interrupt_tight_loops
self.assertNotEqual(iterations, 0)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 0 == 0 |
Can we at least include the fix, until we can come up with a better test? That test fails on 3.9 as well as 3.10 and main. With a 3.9 build and the test in bpo-27194: ./python -m test test_threading -R :
0:00:00 load avg: 0.95 Run tests sequentially
0:00:00 load avg: 0.95 [1/1] test_threading
beginning 9 repetitions
123456789
...test test_threading failed -- Traceback (most recent call last):
File "/home/mark/repos/cpython/Lib/test/test_threading.py", line 1479, in test_can_interrupt_tight_loops
self.assertNotEqual(iterations, 0)
AssertionError: 0 == 0 I don't know what the underlying issue is. Can you observe a failure without the -R flag? |
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: