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

std:win: avoid WSA_FLAG_NO_INHERIT flag and don't use SetHandleInformation on UWP #66835

Merged
merged 1 commit into from
Dec 6, 2019

Conversation

AviKozokin
Copy link
Contributor

@AviKozokin AviKozokin commented Nov 28, 2019

This flag is not supported on Windows 7 before SP1, and on windows server 2008 SP2. This breaks Socket creation & duplication.
This was fixed in a previous PR. cc #26658

This PR: cc #60260 reuses this flag to support UWP, and makes an attempt to handle the potential error.
This version still fails to create a socket, as the error returned by WSA on this case is WSAEINVAL (invalid argument). and not WSAEPROTOTYPE.

MSDN page for WSASocketW (that states the platform support for WSA_FLAG_NO_HANDLE_INHERIT): https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasocketw

CC #26543
CC #26518

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @sfackler (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 28, 2019
@AviKozokin
Copy link
Contributor Author

r? @alexcrichton

@alexcrichton
Copy link
Member

Thanks for the PR! I think it'd be best to keep the current structure though because it atomically creates a socket and sets the no-inherit flag. The current code looks like it already tries to handle the case that it fails and falls back to creating a socket and then setting the no-inherit flag. Does that fallback not seem to work for you? Is there a way we can tweak the fallback to work for you?

@alexcrichton alexcrichton reopened this Dec 2, 2019
@AviKozokin
Copy link
Contributor Author

@alexcrichton
The fallback does not work, because the error value returned from WSASocketW in this case (passing an unsupported value to dwFlags) is not the error value assumed in the code. (WSAEPROTOTYPE).

@alexcrichton
Copy link
Member

Can the list of error codes recognized to trigger the fallback get updated?

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-12-02T17:34:02.9316322Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-12-02T17:34:03.6542947Z ##[command]git config gc.auto 0
2019-12-02T17:34:03.6545992Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-12-02T17:34:03.6548373Z ##[command]git config --get-all http.proxy
2019-12-02T17:34:03.6550868Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/66835/merge:refs/remotes/pull/66835/merge
---
2019-12-02T17:40:23.6220552Z Done!
2019-12-02T17:40:23.6224226Z some tidy checks failed
2019-12-02T17:40:23.6224657Z 
2019-12-02T17:40:23.6224944Z 
2019-12-02T17:40:23.6226161Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor"
2019-12-02T17:40:23.6226720Z 
2019-12-02T17:40:23.6226912Z 
2019-12-02T17:40:23.6227159Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
2019-12-02T17:40:23.6227427Z Build completed unsuccessfully in 0:01:31
2019-12-02T17:40:23.6227427Z Build completed unsuccessfully in 0:01:31
2019-12-02T17:40:23.6277165Z == clock drift check ==
2019-12-02T17:40:23.6283829Z   local time: Mon Dec  2 17:40:23 UTC 2019
2019-12-02T17:40:23.9053461Z   network time: Mon, 02 Dec 2019 17:40:23 GMT
2019-12-02T17:40:23.9053656Z == end clock drift check ==
2019-12-02T17:40:25.1809888Z 
2019-12-02T17:40:25.1908318Z ##[error]Bash exited with code '1'.
2019-12-02T17:40:25.1936553Z ##[section]Starting: Checkout
2019-12-02T17:40:25.1938034Z ==============================================================================
2019-12-02T17:40:25.1938099Z Task         : Get sources
2019-12-02T17:40:25.1938140Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

Copy link
Contributor

@tesuji tesuji left a comment

Choose a reason for hiding this comment

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

What is the CALL file and clippy submodule update?

src/libstd/sys/windows/net.rs Outdated Show resolved Hide resolved
src/libstd/sys/windows/net.rs Outdated Show resolved Hide resolved
@alexcrichton
Copy link
Member

@bors: r+

Thanks!

@bors
Copy link
Contributor

bors commented Dec 2, 2019

📌 Commit fa8b549 has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 2, 2019
@bors
Copy link
Contributor

bors commented Dec 6, 2019

⌛ Testing commit fa8b549 with merge 5f67d71525f973203cd93f8583e3867bb5fff4e1...

@rust-highfive
Copy link
Collaborator

The job dist-various-2 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@bors
Copy link
Contributor

bors commented Dec 6, 2019

💔 Test failed - checks-azure

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 6, 2019
@alexcrichton
Copy link
Member

@bors: retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 6, 2019
@bors
Copy link
Contributor

bors commented Dec 6, 2019

⌛ Testing commit fa8b549 with merge 7b482cd...

bors added a commit that referenced this pull request Dec 6, 2019
std:win: avoid WSA_FLAG_NO_INHERIT flag and don't use SetHandleInformation on UWP

This flag is not supported on Windows 7 before SP1, and on windows server 2008 SP2. This breaks Socket creation & duplication.
This was fixed in a previous PR. cc #26658

This PR: cc #60260 reuses this flag to support UWP, and makes an attempt to handle the potential error.
This version still fails to create a socket, as the error returned by WSA on this case is WSAEINVAL (invalid argument). and not WSAEPROTOTYPE.

MSDN page for WSASocketW (that states the platform support for WSA_FLAG_NO_HANDLE_INHERIT): https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasocketw

CC #26543
CC #26518
@bors
Copy link
Contributor

bors commented Dec 6, 2019

☀️ Test successful - checks-azure
Approved by: alexcrichton
Pushing 7b482cd to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 6, 2019
@bors bors merged commit fa8b549 into rust-lang:master Dec 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants