Ticket #5838 (closed bug: fixed)
integer overflow in rts/RtsUtils:heapOverflow()
| Reported by: | hvr | Owned by: | simonmar |
|---|---|---|---|
| Priority: | high | Milestone: | 7.4.2 |
| Component: | Runtime System | Version: | 7.2.2 |
| Keywords: | Cc: | ||
| Operating System: | Unknown/Multiple | Architecture: | x86_64 (amd64) |
| Type of failure: | Incorrect result at runtime | Difficulty: | Unknown |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description
When failing with a heap exhaustion, the RTS truncates the reported current maximum heap size modulo 232, 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():
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 ints, 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)
Change History
Note: See
TracTickets for help on using
tickets.
