Skip to content

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

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

Merged
merged 2 commits into from
Mar 10, 2021
Merged

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

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

@pitrou: Would you mind to review this fix?

cc @pablogsal

@vstinner
Copy link
Member Author

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

Copy link
Member

@pitrou pitrou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, thanks for fixing this

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

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

@vstinner vstinner deleted the test_signal branch March 10, 2021 14:27
@miss-islington
Copy link
Contributor

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

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

@bedevere-bot
Copy link

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 <[email protected]>
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 <[email protected]>
@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Mar 10, 2021
@bedevere-bot
Copy link

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 <[email protected]>
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 <[email protected]>

Co-authored-by: Victor Stinner <[email protected]>
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.

6 participants