summaryrefslogtreecommitdiff
path: root/rts/Schedule.c
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2017-06-16 15:23:07 -0400
committerBen Gamari <ben@smart-cactus.org>2017-06-18 16:47:28 -0400
commitb9f9670c8cf4eac8798a8cb3e683d0411f9e94ec (patch)
treee625e485653d7f2f785da315f5ffec0ea2b5cfe8 /rts/Schedule.c
parentdf3288000e860856f0fe0ffe67669da9ae5a0a03 (diff)
downloadhaskell-b9f9670c8cf4eac8798a8cb3e683d0411f9e94ec.tar.gz
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.
Diffstat (limited to 'rts/Schedule.c')
-rw-r--r--rts/Schedule.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/rts/Schedule.c b/rts/Schedule.c
index b4f60f8d3a..7950785c4f 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);