Skip to content
  • Ben Gamari's avatar
    rts: Don't madvise if mmap failed · 34464fed
    Ben Gamari authored and Ben Gamari's avatar Ben Gamari committed
    On 32-bit Linux `outofmem` did not fail with the expected out-of-memory
    error message, instead failing with,
    
        outofmem: internal error: getMBlock: mmap: Invalid argument
    
    This happened because, `my_mmap` would attempt to `madvise` even if the
    `mmap` call failed. So while `mmap` returns `ENOMEM` we nevertheless try
    to `madvise`, which clobbers `errno`, giving us the unexpected `EINVAL`
    error. Consequently we don't detect this to be an out-of-memory error.
    
    This should fix #15060.
    
    Test Plan: `make test TEST=outofmem` on i386
    
    Reviewers: simonmar, erikd
    
    Reviewed By: simonmar
    
    Subscribers: rwbarton, thomie, carter
    
    GHC Trac Issues: #15060
    
    Differential Revision: https://phabricator.haskell.org/D4704
    34464fed