Actions
Bug #21702
closed`UNIXSocket` on Windows: suprising results in `#recvfrom` and `#remote_address`
Bug #21702:
`UNIXSocket` on Windows: suprising results in `#recvfrom` and `#remote_address`
Description
Support for UNIXSocket on Windows was added in #19135. Through testing in ruby/spec, I identified unexpected results in two methods:
-
#remote_address.to_salways returns 110 bytes, compared to#local_address.to_swhich returns only needed bytes. Example:
Note how the address is correct, and# test (@addr is remote_address, @b is the socket created with UNIXServer#accept): @addr.to_s.should == @b.local_address.to_s # failure: "\x01\x00D:/a/spec/spec/rubyspec_temp/2032_3/unix.sock\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" == "\x01\x00D:/a/spec/spec/rubyspec_temp/2032_3/unix.sock\x00"#unix_paths are indeed equal, but there are NUL bytes filling the string representation up to 110 bytes. This number does not depend on the length of path name. This is probably related to#pack_sockaddr_un. - Much more worryingly,
UNIXSocket#recvfromdumps 2047 bytes of memory as the remote address:
This seems to be a result of# test: @server.recvfrom(5).should == ['hello', ['AF_UNIX', '']] # failure: ["hello",["AF_UNIX","\x14\xB3v\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\xAB\xCD\x12C\xFF\x7F<snip>"]] == ["hello", ["AF_UNIX", ""]]union_sockaddrhaving achar place_holder[2048]member inside, though it isn't clear why is this used instead ofsockaddr_unmember.
These results are obtained from GitHub runners, as I don't have a machine to test directly. This is the PR in ruby/spec which brought this up: https://github.com/ruby/spec/pull/1300.
Updated by trinistr (Alexander Bulancov) 20 days ago
- Description updated (diff)
Updated by nobu (Nobuyoshi Nakada) 19 days ago
- Status changed from Open to Third Party's Issue
Whether it's a bug or a specification, both are the same as winsock.
Please report to Microsoft.
Actions