Bug 18976 - System.Net.Sockets.Socket Select_internal Error Reporting
Summary: System.Net.Sockets.Socket Select_internal Error Reporting
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2014-04-12 23:34 UTC by Sean Hanna
Modified: 2018-03-13 11:07 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Sean Hanna 2014-04-12 23:34:23 UTC
System.Net.Sockets.Sockets defines icall to ves_icall_System_Net_Sockets_Socket_Select_internal()

This function in turn invokes mono_poll() which uses the *nix errno style format for error reporting. So even in the win32 builds, it takes the winsock select() error codes and maps them to EINTR / EFAULT /EBADF / etc.. error codes.

This ves_icall_System_Net_Sockets_Socket_Select_internal() function passes the *nix errno style error code to caller in an out variable.

This is used by Select() also defined in System.Net.Sockets.Socket

public static void Select (IList checkRead, IList checkWrite, IList checkError, int microSeconds)

When an error occurs the error code (in *nix format) is passed into SocketException (which derives from Win32Exception) and so the *nix format error code is mapped to the equivalent win32 error message directly, and this is an incompatible error code per http://msdn.microsoft.com/en-us/library/windows/desktop/ms681382%28v=vs.85%29.aspx

EINTR = 0x4


    4 (0x4)

    The system cannot open the file.


    14 (0xE)

    Not enough storage is available to complete this operation.

I'm not really messing around with sockets so don't have a test case to provide, but noticed this while browsing the code and decided to share.
Comment 1 Miguel de Icaza [MSFT] 2014-05-23 10:49:53 UTC

Do you have a test case for when this is happening?
Comment 2 Sean Hanna 2014-05-24 10:29:42 UTC
Nope, though i guess you'd start by finding a way to cause mono_poll() to fail with an error. So make poll() fail in environments that have poll(), and you could to go after select() on win32 / apple (if i'm reading it right).

poll() / select() is a blocking operation so that makes it easier. you could probably spin up a socket, kill the fd, and then call select, which will give EFAULT because the fd no longer exists?

Socket s = new Socket(AddressFamily.InterNetwork,
  s.Bind(new IPEndPoint(ipAddress, 11000 + i));



Socket.Select(new[] { s }, null, null, -1);

This is just a mess i threw together in a few minutes, but it might be a starting point
Comment 3 Marek Safar 2018-03-13 11:07:18 UTC
We have not received the requested information. If you are still experiencing this issue please provide all the requested information and reopen the bug report.

Thank you!