[commit: ghc] master: rts: Ensure that new capability count is > 0 (b9f9670)

git at git.haskell.org git at git.haskell.org
Mon Jun 19 12:16:04 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/b9f9670c8cf4eac8798a8cb3e683d0411f9e94ec/ghc

>---------------------------------------------------------------

commit b9f9670c8cf4eac8798a8cb3e683d0411f9e94ec
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Fri Jun 16 15:23:07 2017 -0400

    rts: Ensure that new capability count is > 0
    
    The Haskell wrapper already checks this but we should also check it in the RTS
    to catch non-Haskell callers. See #13832.


>---------------------------------------------------------------

b9f9670c8cf4eac8798a8cb3e683d0411f9e94ec
 rts/Schedule.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/rts/Schedule.c b/rts/Schedule.c
index b4f60f8..7950785 100644
--- a/rts/Schedule.c
+++ b/rts/Schedule.c
@@ -2178,7 +2178,13 @@ setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS)
     Capability *old_capabilities = NULL;
     uint32_t old_n_capabilities = n_capabilities;
 
-    if (new_n_capabilities == enabled_capabilities) return;
+    if (new_n_capabilities == enabled_capabilities) {
+        return;
+    } else if (new_n_capabilities <= 0) {
+        errorBelch("setNumCapabilities: Capability count must be positive");
+        return;
+    }
+
 
     debugTrace(DEBUG_sched, "changing the number of Capabilities from %d to %d",
                enabled_capabilities, new_n_capabilities);



More information about the ghc-commits mailing list