#5838: integer overflow in rts/RtsUtils:heapOverflow()
-----------------------------------------+----------------------------------
 Reporter:  hvr                          |          Owner:                
     Type:  bug                          |         Status:  new           
 Priority:  normal                       |      Component:  Runtime System
  Version:  7.2.2                        |       Keywords:                
       Os:  Unknown/Multiple             |   Architecture:  x86_64 (amd64)
  Failure:  Incorrect result at runtime  |       Testcase:                
Blockedby:                               |       Blocking:                
  Related:                               |  
-----------------------------------------+----------------------------------
 When failing with a heap exhaustion, the RTS truncates the '''reported'''
 ''current maximum heap size'' modulo 2^32, e.g.

 {{{
 $ ghc +RTS -M4G -RTS -e 'sum [1..]'
 Heap exhausted;
 Current maximum heap size is 0 bytes (0 MB);
 use `+RTS -M<size>' to increase it.
 }}}

 This is most probably due to `OutOfHeapHook()` already being called with
 the truncated value from `heapOverflow()`:

 {{{
 #!c
 void
 heapOverflow(void)
 {
     if (!heap_overflow)
     {
         /* don't fflush(stdout); WORKAROUND bug in Linux glibc */
         OutOfHeapHook(0/*unknown request size*/,
                       RtsFlags.GcFlags.maxHeapSize * BLOCK_SIZE);

         heap_overflow = rtsTrue;
     }
 }
 }}}

 which multiplies `RtsFlags.GcFlags.maxHeapSize` and `BLOCK_SIZE` whose
 type are 32-bit `unsigned int`s, causing the result to be wrapped again
 into an `unsigned int`, whereas the result should be upcasted to a `long
 unsigned int` (which at least on 64bit archs would be equivalent to a C99
 `uint64_t`)

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

Reply via email to