#5688: instance Read Integer/Rational/Double readsPrec out of memory and crash
due
to exponential notation
-------------------------------+--------------------------------------------
Reporter: gracjan | Owner: igloo
Type: bug | Status: new
Priority: highest | Milestone: 7.4.2
Component: libraries/base | Version: 6.12.3
Resolution: | Keywords:
Os: Unknown/Multiple | Architecture: Unknown/Multiple
Failure: Runtime crash | Difficulty: Unknown
Testcase: | Blockedby:
Blocking: | Related:
-------------------------------+--------------------------------------------
Comment(by igloo):
Replying to [comment:47 maeder]:
> The precise number given by the input string needs to be converted to
the nearest representable number (by the round-to-nearest rule of IEEE 754
floating-point arithmetic).
Well, I think the only things we're required to accept are what "show" can
produce, which won't have an exponent outside of `MIN_EXP .. MAX_EXP`.
> If we assume that `fromRational` does this correctly, it is enough to
roughly estimate when the value will definitely be +/- Infinity/Zero (in
order to avoid computing an overly large Rational value causing this
ticket).
So what's the actual algorithm? Can it handle all cases correctly?
> It remains to check, if `fromRational` does the right thing. I assume it
replaces "%" by "/" and converts the two arguments from Integer to
Double/Float first. (Where is the code for this?)
`fracExp` in `libraries/base/Text/Read/Lex.hs` makes the `Rational`, and
`fromRational` in `libraries/base/GHC/Float.lhs` converts the `Rational`
to a `Double/Float`.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5688#comment:49>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs