#5688: instance Read Integer/Rational/Double readsPrec out of memory and crash 
due
to exponential notation
---------------------------------+------------------------------------------
    Reporter:  gracjan           |       Owner:                  
        Type:  bug               |      Status:  patch           
    Priority:  highest           |   Milestone:  7.4.1           
   Component:  libraries/base    |     Version:  6.12.3          
    Keywords:                    |          Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |     Failure:  Runtime crash   
  Difficulty:  Unknown           |    Testcase:                  
   Blockedby:                    |    Blocking:                  
     Related:                    |  
---------------------------------+------------------------------------------

Comment(by iustin):

 Replying to [comment:21 maeder]:
 > Before you call read for Integer you can/should check if your string has
 at least one and only digits. Calling read is currently just as risky as
 calling "{{{^}}}" yourself.

 I'm sorry, unless I misunderstood what you meant, this is not an
 acceptable workaround except in trivial programs. This breaks any complex
 data structure that has Int/Integer/Rational fields, and it also breaks
 any libraries which assume that converting a string to an int is safe. For
 example, it also affects Text.JSON:

 {{{
 Prelude Text.JSON> decode "12e1000000000000" :: Result Int
 … hangs …
 }}}

 or the Aeson library:
 {{{
 Prelude Data.Aeson> decode "[12e1000000000000]" :: Maybe [Int]
 … hangs too …
 }}}

 So no, telling people that suddenly "read" is no longer safe and you have
 to do manual checks on its input depending on intended result type is not
 acceptable; this needs to be fixed at compiler level and also, IMHO, the
 fix backported to previous versions.

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

_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to