[Git][ghc/ghc][master] rts: prevent potential divide-by-zero when tickInterval=0

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Tue Jan 31 12:55:30 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
fd8f32bf by Cheng Shao at 2023-01-31T07:54:29-05:00
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.

- - - - -


1 changed file:

- rts/RtsFlags.c


Changes:

=====================================
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;



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fd8f32bf551c34b95275ebb4fe648680013156f3

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fd8f32bf551c34b95275ebb4fe648680013156f3
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230131/8abb7a57/attachment-0001.html>


More information about the ghc-commits mailing list