Skip to content
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

bpo-43406: Fix test_signal.test_stress_modifying_handlers() #24815

Merged
merged 2 commits into from Mar 10, 2021

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Mar 10, 2021

Fix a race condition of test_stress_modifying_handlers() of
test_signal: only raise signals while we are in the
catch_unraisable_exception() context manager.

https://bugs.python.org/issue43406

Fix a race condition of test_stress_modifying_handlers() of
test_signal: only raise signals while we are in the
catch_unraisable_exception() context manager.
@vstinner
Copy link
Member Author

vstinner commented Mar 10, 2021

@pitrou: Would you mind to review this fix?

cc @pablogsal

@vstinner
Copy link
Member Author

vstinner commented Mar 10, 2021

The first commit should fix the race condition:

0:15:05 load avg: 2.58 [137/427/1] test_signal failed (env changed) (1 min 13 sec)
Warning -- Unraisable exception
Traceback (most recent call last):
  File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/threading.py", line 1067, in _wait_for_tstate_lock
    elif lock.acquire(block, timeout):
OSError: Signal 10 ignored due to race condition

I added a second commit which should fix another race condition:

FAIL: test_stress_modifying_handlers (test.test_signal.StressTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vstinner/python/master/Lib/test/test_signal.py", line 1297, in test_stress_modifying_handlers
    self.assertGreater(num_received_signals, 0)
AssertionError: 0 not greater than 0

pitrou
pitrou approved these changes Mar 10, 2021
Copy link
Member

@pitrou pitrou left a comment

+1, thanks for fixing this

@vstinner vstinner merged commit 1fa17e8 into python:master Mar 10, 2021
10 checks passed
@vstinner
Copy link
Member Author

vstinner commented Mar 10, 2021

I wasn't confident about the "ignored" change, so thanks for your reviews :-) I merged my PR.

@miss-islington
Copy link
Contributor

miss-islington commented Mar 10, 2021

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒🤖 I'm not a witch! I'm not a witch!

@miss-islington
Copy link
Contributor

miss-islington commented Mar 10, 2021

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒🤖

@bedevere-bot
Copy link

bedevere-bot commented Mar 10, 2021

GH-24816 is a backport of this pull request to the 3.8 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 10, 2021
…-24815)

Fix a race condition of test_stress_modifying_handlers() of
test_signal: only raise signals while we are in the
catch_unraisable_exception() context manager.
Moreover, don't check if we received at least one
signal if at least one signal got ignored.
(cherry picked from commit 1fa17e8)

Co-authored-by: Victor Stinner <vstinner@python.org>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 10, 2021
…-24815)

Fix a race condition of test_stress_modifying_handlers() of
test_signal: only raise signals while we are in the
catch_unraisable_exception() context manager.
Moreover, don't check if we received at least one
signal if at least one signal got ignored.
(cherry picked from commit 1fa17e8)

Co-authored-by: Victor Stinner <vstinner@python.org>
@bedevere-bot
Copy link

bedevere-bot commented Mar 10, 2021

GH-24817 is a backport of this pull request to the 3.9 branch.

miss-islington added a commit that referenced this pull request Mar 10, 2021
Fix a race condition of test_stress_modifying_handlers() of
test_signal: only raise signals while we are in the
catch_unraisable_exception() context manager.
Moreover, don't check if we received at least one
signal if at least one signal got ignored.
(cherry picked from commit 1fa17e8)

Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner added a commit that referenced this pull request Mar 10, 2021
GH-24817)

Fix a race condition of test_stress_modifying_handlers() of
test_signal: only raise signals while we are in the
catch_unraisable_exception() context manager.
Moreover, don't check if we received at least one
signal if at least one signal got ignored.
(cherry picked from commit 1fa17e8)

Co-authored-by: Victor Stinner <vstinner@python.org>

Co-authored-by: Victor Stinner <vstinner@python.org>
kreathon pushed a commit to kreathon/cpython that referenced this pull request May 2, 2021
…-24815)

Fix a race condition of test_stress_modifying_handlers() of
test_signal: only raise signals while we are in the
catch_unraisable_exception() context manager.
Moreover, don't check if we received at least one
signal if at least one signal got ignored.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants