[GHC] #10792: Bounded Enums [minBound..maxBound] produces runtime error
GHC
ghc-devs at haskell.org
Tue Aug 25 10:36:47 UTC 2015
#10792: Bounded Enums [minBound..maxBound] produces runtime error
-------------------------------------+-------------------------------------
Reporter: | Owner: ekmett
AlexanderThiemann |
Type: bug | Status: new
Priority: normal | Milestone:
Component: Core | Version: 7.10.2
Libraries |
Keywords: | Operating System: Linux
Architecture: | Type of failure: Runtime crash
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Revisions: |
-------------------------------------+-------------------------------------
Consider this code:
{{{#!hs
data MultiHeader
= MultiHeaderCacheControl
| MultiHeaderConnection
| MultiHeaderContentEncoding
-- ...
deriving (Show, Eq, Enum, Bounded, Generic)
instance Hashable MultiHeader
multiHeaderCI :: MultiHeader -> CI.CI BS.ByteString
multiHeaderCI mh =
case mh of
MultiHeaderCacheControl -> "Cache-Control"
MultiHeaderConnection -> "Connection"
MultiHeaderContentEncoding -> "Content-Encoding"
-- ...
multiHeaderMap :: HM.HashMap (CI.CI BS.ByteString) MultiHeader
multiHeaderMap =
HM.fromList $ flip map [minBound..maxBound] $ \mh ->
(multiHeaderCI mh, mh)
}}}
(derived from
https://github.com/agrafix/Spock/blob/9c19c0159d99783aabf896d2742e231a5e85e0a5/src/Web/Spock/Internal/Wire.hs#L83-L121
)
When the multiHeaderMap accessed, a runtime error on GHC7.10.2 running on
*some* [0] [1] Linux architectures is thrown. It does not occur on Mac or
the travis build infrastructure [2].
{{{
uncaught exception: ErrorCall (toEnum{MultiHeader}: tag (-12565) is
outside of enumeration's range (0,12))
}}}
I've marked the bug with 'core libraries', but I am not certain that
that's the origin of it.
[0]: https://github.com/agrafix/Spock/issues/44 (Hydra / NixOS?)
[1]: We've also seen it happen when used in docker with ubuntu:14.04 base
image
[2]: https://travis-ci.org/agrafix/Spock/builds/76877783
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10792>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list