You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
getAddrInfo and getNameInfo lose their errors on Windows #636
On Windows, every failure of getAddrInfo and getNameInfo is raised as the same userError, and what failed and why is lost.
Reproduce
importNetwork.SocketimportqualifiedControl.ExceptionasEimportSystem.IO.Error (ioeGetErrorType)
main =do
r <-E.try (getAddrInfo Nothing (Just"no-such-host.invalid") (Just"80"))
case r ofLeft e ->print (e ::E.IOException) >>print (ioeGetErrorType e)
Right as ->print (map addrAddress (as :: [AddrInfo]))
On Windows 11 with GHC 9.12.4 and master:
user error (Network.Socket.gai_strerror not supported: 11001)
user error
On macOS:
Network.Socket.getAddrInfo (called with preferred socket type/protocol: Nothing, host name: "no-such-host.invalid", service name: "80"): does not exist (nodename nor servname provided, or not known)
does not exist
Cause
configure.ac checks with AC_CHECK_FUNCS([gai_strerror]), which links against a function of that name. In mingw-w64, gai_strerror is a macro for gai_strerrorA, so the check fails (config.log: undefined symbol: gai_strerror) and HAVE_GAI_STRERROR is not defined. gai_strerror in Network/Socket/Info.hsc then throws userError "... not supported" in place of the error it was asked to describe.
Expected
The same as on POSIX: NoSuchThing with the location, the arguments and a description of the code (11001 is WSAHOST_NOT_FOUND).
The codes there are Winsock codes, so getWSErrorDescr in cbits/winSockErr.c can describe them; it already has WSAHOST_NOT_FOUND, WSATRY_AGAIN, WSANO_RECOVERY and WSANO_DATA. That also avoids gai_strerror on Windows, which writes to a static buffer and is not thread-safe. The code could also be kept in ioe_errno, as it is for other Winsock errors (#631).
Activity