[Git][ghc/ghc][master] RTS: Fix restrictive cast

Marge Bot gitlab at gitlab.haskell.org
Wed May 22 20:52:18 UTC 2019



 Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
ecc9366a by Alec Theriault at 2019-05-22T20:48:45Z
RTS: Fix restrictive cast

Commit e75a9afd2989e0460f9b49fa07c1667299d93ee9 added an `unsigned` cast
to account for OSes that have signed `rlim_t` signed. Unfortunately,
the `unsigned` cast has the unintended effect of narrowing `rlim_t` to
only 4 bytes. This leads to some spurious out of memory crashes
(in particular: Haddock crashes with OOM whenn building docs of
`ghc`-the-library).

In this case, `W_` is a better type to cast to: we know it will be
unsigned too and it has the same type as `*len` (so we don't suffer from
accidental narrowing).

- - - - -


1 changed file:

- rts/posix/OSMem.c


Changes:

=====================================
rts/posix/OSMem.c
=====================================
@@ -550,8 +550,8 @@ void *osReserveHeapMemory(void *startAddressPtr, W_ *len)
      * explicitly cast to avoid sign compare error */
     if (!getrlimit(RLIMIT_AS, &limit)
         && limit.rlim_cur > 0
-        && *len > (unsigned) limit.rlim_cur) {
-        *len = (unsigned) limit.rlim_cur;
+        && *len > (W_) limit.rlim_cur) {
+        *len = (W_) limit.rlim_cur;
     }
 #endif
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/ecc9366a0e0db107c286935130837b2222e2dd82

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/ecc9366a0e0db107c286935130837b2222e2dd82
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20190522/6355bef3/attachment-0001.html>


More information about the ghc-commits mailing list