diff --git a/lib/Echidna/Exec.hs b/lib/Echidna/Exec.hs index 490ff163a..b6b0e370d 100644 --- a/lib/Echidna/Exec.hs +++ b/lib/Echidna/Exec.hs @@ -296,10 +296,9 @@ execTxWithCov tx = do if size == 0 then pure Nothing else do -- IO for making a new vec vec <- VMut.new size - -- We use -1 for opIx to indicate that the location was not covered forM_ [0..size-1] $ \i -> VMut.write vec i (0, 0) pure $ Just vec - + case maybeCovVec of Nothing -> pure () Just vec -> do @@ -308,14 +307,13 @@ execTxWithCov tx = do -- bug in another place, investigate. -- ... this should be fixed now, since we use `codeContract` instead -- of `contract` for everything; it may be safe to remove this check. - when (pc < VMut.length vec) $ + when (pc < VMut.length vec) $ do + VMut.modify (fromJust maybeStatsVec) (\(execQty, revertQty) -> (execQty + 1, revertQty)) opIx VMut.read vec pc >>= \case (_, depths, results) | depth < 64 && not (depths `testBit` depth) -> do VMut.write vec pc (opIx, depths `setBit` depth, results `setBit` fromEnum Stop) - VMut.modify (fromJust maybeStatsVec) (\(execQty, revertQty) -> (execQty + 1, revertQty)) opIx writeIORef covContextRef (True, Just (vec, pc)) - (opIx', depths, results) -> do - VMut.modify (fromJust maybeStatsVec) (\(execQty, revertQty) -> (execQty + 1, revertQty)) opIx' + _ -> do modifyIORef' covContextRef $ \(new, _) -> (new, Just (vec, pc)) -- | Get the VM's current execution location diff --git a/lib/Echidna/Output/Source.hs b/lib/Echidna/Output/Source.hs index 11490c964..5b31267d7 100644 --- a/lib/Echidna/Output/Source.hs +++ b/lib/Echidna/Output/Source.hs @@ -199,8 +199,8 @@ srcMapCov sc covMap statMap contracts = do updateLine (Just (r, q)) = Just ((<> unpackTxResults txResults) r, max q execQty) updateLine Nothing = Just (unpackTxResults txResults, execQty) fileStats = Map.lookup c.runtimeCodehash statMap - idxStats | isJust fileStats = (fromJust fileStats) U.! opIx :: StatsInfo - | otherwise = (fromInteger 0, fromInteger 0) :: StatsInfo + idxStats | isJust fileStats = (fromJust fileStats) U.! opIx + | otherwise = (fromInteger 0, fromInteger 0) execQty = fst idxStats Nothing -> acc Nothing -> acc