[GHC] #10792: Bounded Enums [minBound..maxBound] produces runtime error

#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/9c19c0159d99783aabf896d2742e231a5e85e0... ) 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

#10792: Bounded Enums [minBound..maxBound] produces runtime error -------------------------------------+------------------------------------- Reporter: | Owner: ekmett AlexanderThiemann | Type: bug | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 7.10.2 Resolution: | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by simonpj): Since it's a runtime error, can you offer a `Main` module so that if you compile and run the example you get the exception? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10792#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10792: Bounded Enums [minBound..maxBound] produces runtime error -------------------------------------+------------------------------------- Reporter: | Owner: ekmett AlexanderThiemann | Type: bug | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 7.10.2 Resolution: | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by AlexanderThiemann): I've tried to consistently reproduce the bug but it only happens in maybe 5-10% of all runs (see also https://github.com/agrafix/Spock/issues/44#issuecomment-134899484 ). Since removing the minBound..maxBound calls the bug seems to have gone away. Is there any non deterministic behavior in Enums/Bounded? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10792#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC