[Git][ghc/ghc][ghc-8.8] 4 commits: osReserveHeapMemory: handle signed rlim_t

Ben Gamari gitlab at gitlab.haskell.org
Sat Apr 20 14:44:47 UTC 2019



Ben Gamari pushed to branch ghc-8.8 at Glasgow Haskell Compiler / GHC


Commits:
e75a9afd by Fraser Tweedale at 2019-04-19T21:53:43Z
osReserveHeapMemory: handle signed rlim_t

rlim_t is a signed type on FreeBSD, and the build fails with a
sign-compare error.  Add explicit (unsigned) cast to handle this
case.

(cherry picked from commit 0fbad68df0171809bddb48e9753955cc232099eb)

- - - - -
8bbe147d by Ben Gamari at 2019-04-19T21:54:30Z
users-guide: Document how to disable package environments

As noted in #16309 this somehow went undocumented.

(cherry picked from commit 36d380475d9056fdf93305985be3def00aaf6cf7)

- - - - -
d705720b by Ömer Sinan Ağacan at 2019-04-19T21:54:47Z
Fix two bugs in stg_ap_0_fast in profiling runtime

This includes two bug fixes in profiling version of stg_ap_0_fast:

- PAPs allocated by stg_ap_0_fast are now correctly tagged. This
  invariant is checked in Sanity.c:checkPAP.

  (This was originally implemented in 2693eb11f5, later reverted with
  ab55b4ddb7 because it revealed the bug below, but it wasn't clear at
  the time whether the bug was the one below or something in the commit)

- The local variable `untaggedfun` is now marked as a pointer so it
  survives GC.

With this we finally fix all known bugs caught in #15508. `concprog001`
now works reliably with prof+threaded and prof runtimes (with and
without -debug).

(cherry picked from commit 908b4b8659713f0b7a1704ce33c7fa30e3e0ffc3)

- - - - -
f39fb894 by Alexandre Baldé at 2019-04-19T21:55:37Z
Fix error message for './configure' regarding '--with-ghc' [skip ci]

(cherry picked from commit 00245f7777854e9be1eeb4c7363e254d5ad7f25f)

- - - - -


4 changed files:

- configure.ac
- docs/users_guide/packages.rst
- rts/Apply.cmm
- rts/posix/OSMem.c


Changes:

=====================================
configure.ac
=====================================
@@ -168,7 +168,7 @@ then
      $WithGhc is a development snapshot of GHC, version $GhcVersion.
      Bootstrapping using this version of GHC is not supported, and may not
      work.  Use --enable-bootstrap-with-devel-snapshot to try it anyway,
-     or --with-ghc to specify a different GHC to use.])
+     or 'GHC=' to specify a different GHC to use.])
     fi
 fi
 


=====================================
docs/users_guide/packages.rst
=====================================
@@ -579,6 +579,12 @@ must be relative to the location of the package environment file.
 
     Use the package environment in ⟨file⟩, or in
     ``$HOME/.ghc/arch-os-version/environments/⟨name⟩``
+    If set to ``-`` no package environment is read.
+
+.. envvar:: GHC_ENVIRONMENT
+
+    Specifies the path to the package environment file to be used by GHC.
+    Overridden by the :ghc-flag:`-package-env ⟨file⟩|⟨name⟩` flag if set.
 
 In order, ``ghc`` will look for the package environment in the following
 locations:
@@ -588,11 +594,11 @@ locations:
 -  File ``$HOME/.ghc/arch-os-version/environments/name`` if you pass the
    option ``-package-env ⟨name⟩``.
 
--  File ⟨file⟩ if the environment variable ``GHC_ENVIRONMENT`` is set to
+-  File ⟨file⟩ if the environment variable :envvar:`GHC_ENVIRONMENT` is set to
    ⟨file⟩.
 
 -  File ``$HOME/.ghc/arch-os-version/environments/name`` if the
-   environment variable ``GHC_ENVIRONMENT`` is set to ⟨name⟩.
+   environment variable :envvar:`GHC_ENVIRONMENT` is set to ⟨name⟩.
 
 Additionally, unless ``-hide-all-packages`` is specified ``ghc`` will also
 look for the package environment in the following locations:


=====================================
rts/Apply.cmm
=====================================
@@ -60,7 +60,7 @@ stg_ap_0_fast ( P_ fun )
 
 again:
     W_  info;
-    W_ untaggedfun;
+    P_ untaggedfun;
     W_ arity;
     untaggedfun = UNTAG(fun);
     info = %INFO_PTR(untaggedfun);
@@ -106,6 +106,11 @@ again:
                 pap = Hp - SIZEOF_StgPAP + WDS(1);
                 SET_HDR(pap, stg_PAP_info, CCCS);
                 StgPAP_arity(pap) = arity;
+                if (arity <= TAG_MASK) {
+                  // TODO: Shouldn't this already be tagged? If not why did we
+                  // untag it at the beginning of this function?
+                  fun = untaggedfun + arity;
+                }
                 StgPAP_fun(pap)   = fun;
                 StgPAP_n_args(pap) = 0;
                 return (pap);
@@ -117,9 +122,8 @@ again:
                 return (fun);
             } else {
                 // We're going to copy this PAP, and put the new CCS in it
-                fun = untaggedfun;
                 W_ size;
-                size = SIZEOF_StgPAP + WDS(TO_W_(StgPAP_n_args(fun)));
+                size = SIZEOF_StgPAP + WDS(TO_W_(StgPAP_n_args(untaggedfun)));
                 HP_CHK_GEN(size);
                 TICK_ALLOC_PAP(size, 0);
                 // attribute this allocation to the "overhead of profiling"
@@ -127,13 +131,13 @@ again:
                 P_ pap;
                 pap = Hp - size + WDS(1);
                 // We'll lose the original PAP, so we should enter its CCS
-                ccall enterFunCCS(BaseReg "ptr", StgHeader_ccs(fun) "ptr");
+                ccall enterFunCCS(BaseReg "ptr", StgHeader_ccs(untaggedfun) "ptr");
                 SET_HDR(pap, stg_PAP_info, CCCS);
-                StgPAP_arity(pap) = StgPAP_arity(fun);
-                StgPAP_n_args(pap) = StgPAP_n_args(fun);
+                StgPAP_arity(pap) = StgPAP_arity(untaggedfun);
+                StgPAP_n_args(pap) = StgPAP_n_args(untaggedfun);
                 StgPAP_fun(pap)   = StgPAP_fun(fun);
                 W_ i;
-                i = TO_W_(StgPAP_n_args(fun));
+                i = TO_W_(StgPAP_n_args(untaggedfun));
             loop:
                 if (i == 0) {
                     return (pap);


=====================================
rts/posix/OSMem.c
=====================================
@@ -546,10 +546,12 @@ void *osReserveHeapMemory(void *startAddressPtr, W_ *len)
 
 #if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_SYS_TIME_H)
     struct rlimit limit;
+    /* rlim_t is signed on some platforms, including FreeBSD;
+     * explicitly cast to avoid sign compare error */
     if (!getrlimit(RLIMIT_AS, &limit)
         && limit.rlim_cur > 0
-        && *len > limit.rlim_cur) {
-        *len = limit.rlim_cur;
+        && *len > (unsigned) limit.rlim_cur) {
+        *len = (unsigned) limit.rlim_cur;
     }
 #endif
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/compare/d44f54aa8f0125f209637fa9e26a8968dbb31d8b...f39fb89466f85d009ab6c97206ff490406755243

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/compare/d44f54aa8f0125f209637fa9e26a8968dbb31d8b...f39fb89466f85d009ab6c97206ff490406755243
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/20190420/6d61abb5/attachment-0001.html>


More information about the ghc-commits mailing list