diff options
author | Gershom Bazerman <gershomb@gmail.com> | 2019-08-22 12:49:04 -0400 |
---|---|---|
committer | gershomb <gershomb@gmail.com> | 2019-09-01 00:34:05 -0400 |
commit | cfab4abeaffa8b6a78a19bbfa485169a9c772741 (patch) | |
tree | 9085961933d7738ee90bb9b839b89d8442403b65 | |
parent | e56251f647bbb8e851bf3a3fbd9eb2ee7a0666c7 (diff) | |
download | haskell-cfab4abeaffa8b6a78a19bbfa485169a9c772741.tar.gz |
cap max stack size at 32 bit limit (#17019)
-rw-r--r-- | rts/RtsFlags.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c index 5cdf08e9a5..cbc9a333ec 100644 --- a/rts/RtsFlags.c +++ b/rts/RtsFlags.c @@ -134,6 +134,9 @@ void initRtsFlagsDefaults(void) // if getPhysicalMemorySize fails just move along with an 8MB limit if (maxStkSize == 0) maxStkSize = 8 * 1024 * 1024; + // GcFlags.maxStkSiz is 32-bit, so we need to cap to prevent overflow (#17019) + else if (maxStkSize > UINT32_MAX * sizeof(W_)) + maxStkSize = UINT32_MAX * sizeof(W_); RtsFlags.GcFlags.statsFile = NULL; RtsFlags.GcFlags.giveStats = NO_GC_STATS; @@ -1041,7 +1044,7 @@ error = true; case 'K': OPTION_UNSAFE; RtsFlags.GcFlags.maxStkSize = - decodeSize(rts_argv[arg], 2, 0, HS_WORD_MAX) + decodeSize(rts_argv[arg], 2, 0, UINT32_MAX) / sizeof(W_); break; |