Commit 98494031 authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari

base: Validate input in setNumCapabilities

Test Plan: validate

Reviewers: austin, hvr, erikd, simonmar

Subscribers: rwbarton, thomie

GHC Trac Issues: #13832

Differential Revision: https://phabricator.haskell.org/D3652
parent 430137c4
......@@ -379,7 +379,9 @@ to avoid contention with other processes in the machine.
@since 4.5.0.0
-}
setNumCapabilities :: Int -> IO ()
setNumCapabilities i = c_setNumCapabilities (fromIntegral i)
setNumCapabilities i
| i <= 0 = fail $ "setNumCapabilities: Capability count ("++show i++") must be positive"
| otherwise = c_setNumCapabilities (fromIntegral i)
foreign import ccall safe "setNumCapabilities"
c_setNumCapabilities :: CUInt -> IO ()
......
import GHC.Conc
main :: IO ()
main = setNumCapabilities 0
T13832: user error (setNumCapabilities: Capability count (0) must be positive)
......@@ -372,4 +372,4 @@ test('T12497', [ unless(opsys('mingw32'), skip)
run_command, ['$MAKE -s --no-print-directory T12497'])
test('T12903', [when(opsys('mingw32'), skip)], compile_and_run, [''])
test('T13832', exit_code(1), compile_and_run, ['-threaded'])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment