File tree 2 files changed +14
-2
lines changed
pact-repl/Pact/Core/IR/Eval/Direct 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -649,13 +649,15 @@ sysOnlyEnv e
649
649
650
650
evalWithStackFrame :: i -> StackFrame i -> Maybe Type -> EvalM e b i (EvalValue e b i ) -> EvalM e b i (EvalValue e b i )
651
651
evalWithStackFrame info sf mty act = do
652
+ checkRecursion
652
653
esStack %= (sf: )
653
654
#ifdef WITH_FUNCALL_TRACING
654
655
timeEnter <- liftIO $ getTime ProcessCPUTime
655
656
esTraceOutput %= (TraceFunctionEnter timeEnter sf info: )
656
657
#endif
657
658
v <- act
658
659
esStack %= safeTail
660
+ esCheckRecursion %= getPrevRecCheck
659
661
pv <- enforcePactValue info v
660
662
rtcEnabled <- isExecutionFlagSet FlagDisableRuntimeRTC
661
663
unless rtcEnabled $ maybeTCType info mty pv
@@ -664,6 +666,16 @@ evalWithStackFrame info sf mty act = do
664
666
esTraceOutput %= (TraceFunctionExit timeExit sf info: )
665
667
#endif
666
668
return (VPactValue pv)
669
+ where
670
+ checkRecursion = do
671
+ RecursionCheck currentCalled <- uses esCheckRecursion NE. head
672
+ let qn = fqnToQualName (_sfName sf)
673
+ when (S. member qn currentCalled) $ throwExecutionError info (RuntimeRecursionDetected qn)
674
+ esCheckRecursion %= NE. cons (RecursionCheck (S. insert qn currentCalled))
675
+ getPrevRecCheck (_ :| l) = case l of
676
+ top : rest -> top :| rest
677
+ [] -> (RecursionCheck mempty ) :| []
678
+
667
679
{-# INLINE evalWithStackFrame #-}
668
680
669
681
applyLamUnsafe
Original file line number Diff line number Diff line change 27
27
)
28
28
29
29
(env-gasmodel "table")
30
- (env-gaslimit 10 ) ; ensures test does not run forever in case recursion breaks
30
+ (env-gaslimit 1000 ) ; ensures test does not run forever in case recursion breaks
31
31
32
32
33
- (expect-failure "Recursion should fail @ runtime" (knot2.callF knot1))
33
+ (expect-failure "Recursion should fail @ runtime" "Recursion detected by the runtime. Recursing in function: knot2.callF" (knot2.callF knot1))
You can’t perform that action at this time.
0 commit comments