#7361: Segmentation fault on 5f37e0c71ff4af8539c5aebc739b006b4f0c6ebf
---------------------------------+------------------------------------------
    Reporter:  bgamari           |       Owner:  simonmar        
        Type:  bug               |      Status:  infoneeded      
    Priority:  highest           |   Milestone:  7.8.1           
   Component:  Compiler          |     Version:  7.7             
    Keywords:                    |          Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |     Failure:  Runtime crash   
  Difficulty:  Unknown           |    Testcase:                  
   Blockedby:                    |    Blocking:                  
     Related:                    |  
---------------------------------+------------------------------------------

Comment(by bgamari):

 Well, it seems that `nextIndex` isn't wrapping correctly when used in
 `uniformWord32`. Currently it is implemented as,
 {{{
 nextIndex :: Integral a => a -> Int
 nextIndex i = fromIntegral j
     where j = fromIntegral (i+1) :: Word8
 }}}
 If I trace the index values over iterations of `uniformWord32`, I find
 that they grow beyond 256, resulting in the crash.

 If I implement `nextIndex` with a simple `mod`, on the other hand, things
 work fine,
 {{{
 nextIndex :: Integral a => a -> Int
 nextIndex i = fromIntegral $ (i + 1) `mod` 256
 }}}

 Simon, is it possible that the optimizer could be now optimizing out the
 cast?

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7361#comment:29>
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