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

Android abstract unix domain sockets AddressKind correction #50079

Merged
merged 2 commits into from
Apr 24, 2018

Conversation

NickAtAccuPS
Copy link
Contributor

@NickAtAccuPS NickAtAccuPS commented Apr 19, 2018

The prior check causes abstract unix domain sockets to return AddressKind::Unnamed instead of AddressKind::Abstract on Android.

Other than the immediately proceeding comment "macOS seems to return a len of 16 and a zeroed sun_path for unnamed addresses" the check as-implemented does not seem to have alternative explanation. I couldn't find an alternative explanation while stepping though git blame. I suspect the AddressKind::Unnamed nonzero check should instead be if macos, length 16, and zeroed array. @sfackler could you comment on this, the code as-is is the same from your initial addition of abstract uds support.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 of your PR failed on Travis (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.

[00:05:07] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:05:08] tidy error: /checkout/src/libstd/sys/unix/ext/net.rs:217: line longer than 100 chars
[00:05:09] some tidy checks failed
[00:05:09] 
[00:05:09] 
[00:05:09] 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" "--quiet"
[00:05:09] 
[00:05:09] 
[00:05:09] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:05:09] Build completed unsuccessfully in 0:02:04
[00:05:09] Build completed unsuccessfully in 0:02:04
[00:05:09] make: *** [tidy] Error 1
[00:05:09] Makefile:79: recipe for target 'tidy' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0c135dd7
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

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)

@NickAtAccuPS
Copy link
Contributor Author

r? @sfackler

@sfackler
Copy link
Member

Why are you looking for an alternative explanation? The check is for not Linux because BSDs share OSX's behavior.

@sfackler
Copy link
Member

We have checks that addresses are unnamed as appropriate, and those should be running on Android as well: https://github.com/NickAtAccuPS/rust/blob/da6142c81057342d8d6686ae4078995aab73b5bc/src/libstd/sys/unix/ext/net.rs#L1747

Did you see this not working in practice? Maybe this behavior changed at some point in Android releases?

@pietroalbini pietroalbini added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 20, 2018
@pietroalbini pietroalbini changed the title (Don't merge) Android abstract unix domain sockets AddressKind correction WIP: Android abstract unix domain sockets AddressKind correction Apr 20, 2018
@pietroalbini
Copy link
Member

Thanks for this PR! Changed the title to WIP so bors actually prevents merging until the prefix is removed from the title :) (also, highfive is down, assigned label+reviewer)

@NickAtAccuPS
Copy link
Contributor Author

NickAtAccuPS commented Apr 23, 2018

The check is for not Linux because BSDs share OSX's behavior.

That's the context I was missing.

The problem I'm seeing in the wild is that while libstd doesn't handle creating/pairing an abstract UDS, it does handle them correctly if UnixStream et al. are manually constructed with from_raw_fd() with an abstract namespaced socket fd on Linux. This is how mio_uds is currently implemented.

self.address() is used for the fmt::Debug and checks for abstract sockets correctly on Linux but incorrectly returns that the socket is unnamed on Android. This PR fixes that issue specifically.

Sorry that this wasn't clear from the first comment; I had forgotten that libstd doesn't support abstract socket creation.

I don't think the test_connect_unix_datagram() test is relevant to this PR; @sfackler did you mean to link to the abstract_namespace_not_allowed() test? Still that's just checking for connecting to an abstract UDS via libstd functions, not manually populating a UnixStream with a connected abstract socket fd as mio_uds demonstrates.

@sfackler
Copy link
Member

Ah, I was thinking that the issue was failing to detect unnamed addresses, not abstract addresses.

@sfackler
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Apr 24, 2018

📋 Looks like this PR is still in progress, ignoring approval

@pietroalbini pietroalbini changed the title WIP: Android abstract unix domain sockets AddressKind correction Android abstract unix domain sockets AddressKind correction Apr 24, 2018
@pietroalbini
Copy link
Member

@sfackler you need to r+ this again.

@kennytm
Copy link
Member

kennytm commented Apr 24, 2018

@bors r=sfackler

@bors
Copy link
Contributor

bors commented Apr 24, 2018

📌 Commit da6142c has been approved by sfackler

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 24, 2018
bors added a commit that referenced this pull request Apr 24, 2018
Android abstract unix domain sockets AddressKind correction

The prior check causes abstract unix domain sockets to return AddressKind::Unnamed instead of AddressKind::Abstract on Android.

Other than the immediately proceeding comment "macOS seems to return a len of 16 and a zeroed sun_path for unnamed addresses" the check as-implemented does not seem to have alternative explanation. I couldn't find an alternative explanation while stepping though git blame. I suspect the AddressKind::Unnamed nonzero check should instead be if macos, length 16, and zeroed array. @sfackler could you comment on this, the code as-is is the same from your initial addition of abstract uds support.
@bors
Copy link
Contributor

bors commented Apr 24, 2018

⌛ Testing commit da6142c with merge 38e251b...

@bors
Copy link
Contributor

bors commented Apr 24, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: sfackler
Pushing 38e251b to master...

@bors bors merged commit da6142c into rust-lang:master Apr 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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