summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCheng Shao <terrorjack@type.dance>2023-01-30 14:12:59 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-01-31 07:54:29 -0500
commitfd8f32bf551c34b95275ebb4fe648680013156f3 (patch)
treee78a5e5ae6f52c68488dc659b4d260a3ee474021
parent7cbdaad0396cee561f125c95f3352cebabd8ed99 (diff)
downloadhaskell-fd8f32bf551c34b95275ebb4fe648680013156f3.tar.gz
rts: prevent potential divide-by-zero when tickInterval=0
This patch fixes a few places in RtsFlags.c that may result in divide-by-zero error when tickInterval=0, which is the default on wasm. Fixes #22603.
-rw-r--r--rts/RtsFlags.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c
index bb82ea4515..a1823b90b5 100644
--- a/rts/RtsFlags.c
+++ b/rts/RtsFlags.c
@@ -243,7 +243,8 @@ void initRtsFlagsDefaults(void)
RtsFlags.TraceFlags.nullWriter = false;
#endif
-#if defined(PROFILING)
+// See Note [No timer on wasm32]
+#if defined(PROFILING) && !defined(wasm32_HOST_ARCH)
// When profiling we want a lot more ticks
RtsFlags.MiscFlags.tickInterval = USToTime(1000); // 1ms
#else
@@ -1853,7 +1854,7 @@ static void normaliseRtsOpts (void)
RtsFlags.MiscFlags.tickInterval);
}
- if (RtsFlags.ConcFlags.ctxtSwitchTime > 0) {
+ if (RtsFlags.ConcFlags.ctxtSwitchTime > 0 && RtsFlags.MiscFlags.tickInterval != 0) {
RtsFlags.ConcFlags.ctxtSwitchTicks =
RtsFlags.ConcFlags.ctxtSwitchTime /
RtsFlags.MiscFlags.tickInterval;
@@ -1861,7 +1862,7 @@ static void normaliseRtsOpts (void)
RtsFlags.ConcFlags.ctxtSwitchTicks = 0;
}
- if (RtsFlags.ProfFlags.heapProfileInterval > 0) {
+ if (RtsFlags.ProfFlags.heapProfileInterval > 0 && RtsFlags.MiscFlags.tickInterval != 0) {
RtsFlags.ProfFlags.heapProfileIntervalTicks =
RtsFlags.ProfFlags.heapProfileInterval /
RtsFlags.MiscFlags.tickInterval;
@@ -1869,7 +1870,7 @@ static void normaliseRtsOpts (void)
RtsFlags.ProfFlags.heapProfileIntervalTicks = 0;
}
- if (RtsFlags.TraceFlags.eventlogFlushTime > 0) {
+ if (RtsFlags.TraceFlags.eventlogFlushTime > 0 && RtsFlags.MiscFlags.tickInterval != 0) {
RtsFlags.TraceFlags.eventlogFlushTicks =
RtsFlags.TraceFlags.eventlogFlushTime /
RtsFlags.MiscFlags.tickInterval;