Repository navigation
gh-158646: Fix race in test_shutdown_corrupted_ssl_sends_close_notify - #160848
Merged
Merged
Conversation
…notify The server called unwrap() right after corrupting the client's TLS stream, which sent its own close_notify to a client that was about to close its socket. That turned the client's close into a TCP reset, and on Windows a reset discards the client's close_notify that is still unread, so the server failed with WinError 10054 (or 10053). Wait for the client's close_notify with recv() before calling unwrap(). A ragged EOF without close_notify still makes unwrap() raise SSLError, so the test keeps catching the pythongh-98078 regression. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Contributor
Author
|
@vstinner I believe this tiny change fixes the flaky test on Windows. |
Contributor
Author
|
ASan/TSan failures are not related to the PR (only Restarting. |
|
Thanks @asvetlov for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15. |
|
Sorry, @asvetlov, I could not cleanly backport this to Please backport manually with cherry_picker, see the devguide for more information. |
|
Sorry, @asvetlov, I could not cleanly backport this to Please backport manually with cherry_picker, see the devguide for more information. |
Contributor
Author
|
The test doesn't exist on 3.15, don't backport |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The server side of
test_shutdown_corrupted_ssl_sends_close_notifycalledunwrap()right after corrupting the client's TLS stream, which sent its own close_notify to a client that was about to close its socket. That turned the client's close into a TCP reset. Linux still delivers data queued before a reset, but Windows discards it, so the server's read failed withWinError 10054(sometimes10053) even though the client had sent close_notify correctly. The asyncio code is fine; the test was racy.Fix: the server now waits for the client's close_notify with
recv()(which returnsb''on a clean TLS EOF) before callingunwrap(). A ragged EOF without close_notify still makesunwrap()raiseSSLError, so the test keeps catching the gh-98078 regression (verified by temporarily removing the gh-98078 send insslproto.py).Verified on a Windows 11 x64 debug build:
test_asyncio.test_sslprotoon Windows and Linux🤖 Generated with Claude Code