Skip to content

Commit

Permalink
Fix stack overflow by adding a missing bang
Browse files Browse the repository at this point in the history
The local `qProc` function in `Cardano.BM.Backend.Switchboard` loops by
calling itself recursively, passing in the same `MVar MessageCounter` each
time. However, `MessageCounter` was missing a bang on its `mcCountersMap`
field, which contains `HM.HashMap Text Word64`. Even though the `HashMap` is a
strict one, if you don't force it, you're still accumulating thunks. And as
the `MVar` containing the `MessageCounter` was passed recursively, this
resulted in a stack overflow instead of running out of (heap) memory.

Fix it by adding the missing bang.

This should fix IntersectMBO/cardano-node#370.
  • Loading branch information
mrBliss committed Dec 11, 2019
1 parent 827bce8 commit 327bdf4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion iohk-monitoring/src/Cardano/BM/Data/MessageCounter.lhs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Data structure holding essential info for message counters.
\begin{code}
data MessageCounter = MessageCounter
{ mcStart :: {-# UNPACK #-} !UTCTime
, mcCountersMap :: HM.HashMap Text Word64
, mcCountersMap :: !(HM.HashMap Text Word64)
}
deriving (Show)
Expand Down

0 comments on commit 327bdf4

Please sign in to comment.