WSL icon indicating copy to clipboard operation
WSL copied to clipboard

System.ArgumentException: Value does not fall within the expected range. at System.Net.Sockets.Socket.SetSocketOption (System.Net.Sockets.SocketOptionLevel optionLevel, System.Net.Sockets.SocketOptionName optionName, System.Int32 optionValue) on Mono

Open imkow opened this issue 9 years ago • 14 comments

Please use the following bug reporting template to help produce actionable and reproducible issues. Please try to ensure that the reproduction is minimal so that the team can go through more bugs!

  • A brief description With Mono 4.8, it's not a mono problem, I checked on other Ubuntu 14.04 16.04 machines. when starts XSocketsServer.Start() it throws Got a bad hardware address length for an AF_PACKET 16 8 // this may or may not matter Got a bad hardware address length for an AF_PACKET 16 8 2017-01-28 07:23:09 [Error] Error in XSocketServer.Start() System.ArgumentException: Value does not fall within the expected range. at System.Net.Sockets.Socket.SetSocketOption (System.Net.Sockets.SocketOptionLevel optionLevel, System.Net.Sockets.SocketOptionName optionName, System.Int32 optionValue) [0x00023]

  • Expected results runs without problem, and it ran no problem on earlier builds (I don't remember build number)

  • Actual results (with terminal output if applicable) Got a bad hardware address length for an AF_PACKET 16 8 Got a bad hardware address length for an AF_PACKET 16 8 2017-01-28 07:23:09 [Error] Error in XSocketServer.Start() System.ArgumentException: Value does not fall within the expected range. at System.Net.Sockets.Socket.SetSocketOption (System.Net.Sockets.SocketOptionLevel optionLevel, System.Net.Sockets.SocketOptionName optionName, System.Int32 optionValue) [0x00023] in <1ac50aac877347fd9fa1bbebe4ae149e>:0 at System.Net.Sockets.Socket.set_DontFragment (System.Boolean value) [0x00009] in <1ac50aac877347fd9fa1bbebe4ae149e>:0 at System.Net.Sockets.Socket.SocketDefaults () [0x00009] in <1ac50aac877347fd9fa1bbebe4ae149e>:0 at System.Net.Sockets.Socket..ctor (System.Net.Sockets.AddressFamily addressFamily, System.Net.Sockets.SocketType socketType, System.Net.Sockets.ProtocolType protocolType) [0x00095] in <1ac50aac877347fd9fa1bbebe4ae149e>:0 at System.Net.Sockets.TcpListener..ctor (System.Net.IPEndPoint localEP) [0x0002d] in <1ac50aac877347fd9fa1bbebe4ae149e>:0 at XSockets.Server.XSocketServer+d__16.MoveNext () [0x0012a] in <4883760312cf4ca3ab413ae42c1df4f3>:0

  • Your Windows build number tested on 10.0.15014, 10.0.15019

  • Steps / All commands required to reproduce the error from a brand new installation create a project, reference XSockets.Server 5.7.1 from nugget, and create a class inherits XSocketController, new the class, start the server.

  • Strace of the failing command N/A

  • Required packages and commands to install Mono 4.8, it's RC for now, install instruction for beta Mono packages: http://www.mono-project.com/docs/getting-started/install/linux/#debian-ubuntu-and-derivatives-beta-channel

See our contributing instructions for assistance.

imkow avatar Jan 27 '17 23:01 imkow

@imkow - Thanks for the bug report and the feedback. Can you share out an strace? That would be really useful in this case. To collect an strace:

strace -o <strace_file> -ff <failing command>

sunilmut avatar Jan 27 '17 23:01 sunilmut

@sunilmut - here is the trace:

mono_sockets_WSL_trace.zip

imkow avatar Jan 28 '17 00:01 imkow

Trace file is generated with Mono 4.9 snapshot ci packages: http://www.mono-project.com/docs/getting-started/install/linux/ci-packages/

imkow avatar Jan 28 '17 00:01 imkow

Guh. I've never understood why so many coders think it is a good idea to spin on gettimeofday(). Anyway, this seems to be the problem:

setsockopt(4, SOL_IP, IP_MTU_DISCOVER, [0], 4) = -1 EINVAL (Invalid argument)

Ignoring the gettimeofday() storm it fails with dotnet System.ArgumentException soon afterward.

#69 #717

therealkenc avatar Jan 28 '17 00:01 therealkenc

I've created a new ticket on uservoice: https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/17872294-setsockopt-fd-ipproto-ip-ip-mtu-discover-fla

#69 #717

imkow avatar Jan 28 '17 14:01 imkow

Thanks for reporting this. We support IP_MTU_DISCOVER for datagram inet sockets, but not for stream inet sockets. This is actually a Windows networking (WSK) limitation and we are working with the networking team for them to add support.

JasonLinMS avatar Feb 08 '17 19:02 JasonLinMS

Full support from the networking team would be nice, but 90% of the value would be achieved by silently ignoring the option, rather than returning an error for it.

(I have a non-public project which runs on Mono on Linux, but not on Windows, because of this issue. I don't care whether there's MTU discovery, but this results in a crash-on-startup.)

jimrandomh avatar Jun 14 '17 02:06 jimrandomh

@jimrandomh - Thanks for your comment. Full support for IP_MTU_DISCOVER has already been checked-in the dev branch, sometime back. It should soon be in the Insider builds.

sunilmut avatar Jun 14 '17 19:06 sunilmut

This should be fixed in Insider build 16215

sunilmut avatar Jun 22 '17 18:06 sunilmut

I got these using Ubuntu 16.04.3 LTS, Release 16.04 and mono 5.2.0.215: Is this related?

.NET Runtime Version: 4.0.30319.42000 Operating System Version: Unix 4.4.0.43 Working Directory: x Language: fr-CA Process Id : 30581 2017-08-25 08:41:09,592 [Main] INFO - Mono Version : 5.2.0.215 (tarball Mon Aug 14 15:46:23 UTC 2017) System.ArgumentException: Value does not fall within the expected range. at System.Net.Sockets.Socket.SetSocketOption (System.Net.Sockets.SocketOptionLevel optionLevel, System.Net.Sockets.SocketOptionName optionName, System.Int 32 optionValue) [0x00023] in :0 at System.Net.Sockets.Socket.set_DontFragment (System.Boolean value) [0x00009] in :0 at System.Net.Sockets.Socket.SocketDefaults () [0x00009] in :0 at System.Net.Sockets.Socket..ctor (System.Net.Sockets.AddressFamily addressFamily, System.Net.Sockets.SocketType socketType, System.Net.Sockets.ProtocolT ype protocolType) [0x00095] in :0 at System.Net.Sockets.TcpListener..ctor (System.Net.IPAddress localaddr, System.Int32 port) [0x00046] in :0 at .StandardConnection.StartServer (System.String ipAddress, System.Int32 port, System.Int32 maxConnections) [0x0002 a] in d:\s-backup\CFF\RJ.Prod\Foundations\Agents\AgentCommunicationLayer\StandardConnection.cs:67 FATAL - : Error reading configuration file.

FelixBrunet avatar Aug 25 '17 12:08 FelixBrunet

Same while running xsp Completely fresh install of Bash on Windows with just mono and xsp installed Running Bash on Windows with Ubuntu 14.04.5 LTS Mono JIT compiler version 5.2.0.215

IliqNikushev avatar Sep 02 '17 08:09 IliqNikushev

@FelixBrunet & @IliqNikushev - What is your Windows version (output of the ver command from CMD)?

Also, it's difficult to say which socket option it is tripping on without a trace. Can you collect a trace and share it out? strace -o <trace_file> -ff <failing_cmd>

sunilmut avatar Sep 05 '17 19:09 sunilmut

Microsoft Windows [Version 10.0.15063] fail socket mono.zip

FelixBrunet avatar Sep 12 '17 18:09 FelixBrunet

@FelixBrunet - Thanks. setsockopt(4, SOL_IP, IP_MTU_DISCOVER, [0], 4) = -1 EINVAL (Invalid argument) As mentioned above, the issue is resolved in the Insider build 16215 (you are on 15063), which will also be available in Fall Creators Update.

sunilmut avatar Sep 13 '17 21:09 sunilmut