RtsFlags: allow +RTS -K0
authorBen Gamari <bgamari.foss@gmail.com>
Mon, 27 Nov 2017 14:46:55 +0000 (09:46 -0500)
committerBen Gamari <ben@smart-cactus.org>
Mon, 27 Nov 2017 15:20:55 +0000 (10:20 -0500)
Reviewers: erikd, simonmar, hvr

Reviewed By: hvr

Subscribers: hvr, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4238

rts/RtsFlags.c
testsuite/tests/rts/all.T
testsuite/tests/rts/stack004.hs [new file with mode: 0644]

index ecb9228..39b1273 100644 (file)
@@ -1015,7 +1015,7 @@ error = true;
               case 'K':
                   OPTION_UNSAFE;
                   RtsFlags.GcFlags.maxStkSize =
-                      decodeSize(rts_argv[arg], 2, sizeof(W_), HS_WORD_MAX)
+                      decodeSize(rts_argv[arg], 2, 0, HS_WORD_MAX)
                       / sizeof(W_);
                   break;
 
index 935e10e..d5eaa76 100644 (file)
@@ -97,6 +97,9 @@ test('stack003', [ omit_ways('ghci'), # uses unboxed tuples
                    extra_run_opts('500000 +RTS -kc1k -kb100 -K96m -RTS') ],
                  compile_and_run, [''])
 
+# Test that +RTS -K0 (e.g. no stack limit) parses correctly
+test('stack004', [extra_run_opts('+RTS -K0 -RTS') ], compile_and_run, [''])
+
 test('atomicinc', [ c_src, only_ways(['normal','threaded1', 'threaded2']) ], compile_and_run, [''])
 test('atomicxchg', [ c_src, only_ways(['threaded1', 'threaded2']) ],
 compile_and_run, [''])
diff --git a/testsuite/tests/rts/stack004.hs b/testsuite/tests/rts/stack004.hs
new file mode 100644 (file)
index 0000000..4c9e337
--- /dev/null
@@ -0,0 +1,10 @@
+module Main where
+
+import Control.Monad
+import GHC.RTS.Flags
+
+-- Ensure that +RTS -K0 is parsed
+main :: IO ()
+main = do
+    flags <- getGCFlags
+    unless (maxStkSize flags == 0) $ putStrLn "uh oh"