[network] #1: unpackFamily on Windows fails match
network
libraries at haskell.org
Sat Jan 17 18:12:20 EST 2009
#1: unpackFamily on Windows fails match
------------------------+---------------------------------------------------
Reporter: igloo | Owner: somebody
Type: defect | Status: new
Priority: major | Milestone:
Component: component1 | Version:
Keywords: |
------------------------+---------------------------------------------------
Initially reported here: http://hackage.haskell.org/trac/ghc/ticket/2250
----
In the HostEntry returned by Network.BSD.getHostByName, evaluating the
hostFamily field causes the following error, which is pointing at the
unpackFamily function:
{{{
*** Exception: Network/Socket.hsc:(1711,17)-(1777,13): Non-exhaustive
patterns in case
}}}
This occurs with 6.8.2 and 6.9.20080323 i386. The machine is running
Windows Server 2008 x64.
----
I modified Network/BSD.hs to trace out the h_addrtype variable in Storable
`HostEntry`'s peek, and it had the value 0x40002. The corresponding
variable in the C struct should be a short, but is inferred to be CInt in
the Haskell source, probably thanks to unpackFamily having type CInt ->
Family. Due to that, it reads the family as an int, consuming the
following length field as well.
I hacked past this by giving the peek of h_addrtype an annotation of "::
IO CShort" and adding a fromIntegral at the call to unpackFamily to
convert it to the CInt that the unpackFamily function expects.
----
Great stuff, thanks! It looks like it should be `CSaFamily` rather than
`CInt`. Likewise `packFamily`, and I expect the whole library could do
with an audit.
----
I can reproduce the exact bug on the following combinations:
- GHC 6.8.2, x86, Windows XP - GHC 6.8.3, x86, Windows XP - GHC 6.8.2,
x86, Windows Vista - GHC 6.8.3, x86, Windows Vista - GHC 6.8.2, x64,
Windows Vista - GHC 6.8.3, x64, Windows Vista
--
Ticket URL: <http://trac.haskell.org/network/ticket/1>
network <http://projects.haskell.org/network/>
Networking-related facilities
More information about the Libraries
mailing list