[GHC] #7483: Broken Read instance for Data.Fixed ("no parse" in legitimate cases).

GHC ghc-devs at haskell.org
Tue Jun 24 10:27:45 UTC 2014


#7483: Broken Read instance for Data.Fixed ("no parse" in legitimate cases).
------------------------------------------------+--------------------------
        Reporter:  navaati                      |            Owner:
            Type:  bug                          |           Status:  closed
        Priority:  normal                       |        Milestone:
       Component:  libraries/base               |          Version:  7.6.1
      Resolution:  fixed                        |         Keywords:
Operating System:  Unknown/Multiple             |     Architecture:
 Type of failure:  Incorrect result at runtime  |  Unknown/Multiple
       Test Case:  readFixed001                 |       Difficulty:
        Blocking:                               |  Unknown
                                                |       Blocked By:
                                                |  Related Tickets:  #4502
------------------------------------------------+--------------------------

Comment (by Herbert Valerio Riedel <hvr@…>):

 In [changeset:"c1035d51edaac2f388a0630e2ad25391e7e3c1ab/ghc"]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="c1035d51edaac2f388a0630e2ad25391e7e3c1ab"
 Fix regression in Data.Fixed Read instance (re #9231)

 `convertFixed` operates under the wrong assumption that
 `Data.Fixed.resolution` returns a base-10 exponent `e`, whereas it
 actually returns the power-of-10 value `10^e`.

 So while the code (that was introduced in 5f19f951d8 / #7483) happens to
 compute a correct result by coincidence, it allocates huge integer values
 in the process (i.e. `10^(10^e)`) which cause long computations which
 eventually result in out-of-memory conditions for `e`-values beyond
 `Data.Fixed.Milli`.

 A proper long-term fix would probably be to extend the `HasResolution`
 type-class to have a 2nd method providing the `e` value.

 Signed-off-by: Herbert Valerio Riedel <hvr at gnu.org>

 Differential Revision: https://phabricator.haskell.org/D25
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/7483#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list