Skip to content

Commit 24d0636

Browse files
Merge pull request #230 from mijovic/upstream-threading-timeout
Threading and timeout fixes
2 parents e9cff61 + c5febdd commit 24d0636

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

act.cabal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ executable act
8686
main-is: Main.hs
8787
hs-source-dirs: src/CLI
8888
default-language: Haskell2010
89+
-- Enable multicore execution, using all available cores by default.
90+
ghc-options: -threaded "-with-rtsopts=-N"
8991
build-depends: act
9092
if os(darwin)
9193
extra-libraries: c++

src/Act/CLI.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,14 @@ equivCheck actspec sol' vy' code' initcode' layout' sources' solver' timeout deb
215215
checkTypeConstraints specsContents solver' timeout debug' constraints
216216
checkUpdateAliasing (Act store contracts) solver' timeout debug'
217217
cmap <- createContractMap contracts inputsMap
218-
res <- runEnv (Env config) $ Solvers.withSolvers solver' cores 1 (naturalFromInteger <$> timeout) $ \solvers ->
218+
-- --smttimeout is documented (and used by `act type`) in milliseconds,
219+
-- but withSolvers takes seconds: hevm's mkTimeout multiplies by 1000 for
220+
-- the solver flag. Passing milliseconds through unconverted turned a 60s
221+
-- budget into 60000s, so hard queries never timed out - they blocked the
222+
-- solver instance until the whole run was abandoned. Round up so small
223+
-- values do not become 0 (no limit).
224+
let timeoutSecs = (\t -> naturalFromInteger (max 1 ((t + 999) `div` 1000))) <$> timeout
225+
res <- runEnv (Env config) $ Solvers.withSolvers solver' cores 1 timeoutSecs $ \solvers ->
219226
checkContracts solvers store cmap
220227
case res of
221228
Success _ -> pure ()

0 commit comments

Comments
 (0)