Using `key this`, `observer this`, `signatory this` in template-local let clause causes infinite loop.
See original GitHub issueI confirm that, if this is a bug that has security implications, I already contacted security@digitalasset.com and followed the responsible disclosure policy.
I confirm that this is not a question or a request for technical support by the community, for which the Daml forum is available.
Affected Daml version
2.0.0
Bug description
Using the expression key this
in a template-local let
clause seems to cause some sort of infinite recursion.
To reproduce
- Create a daml project with the below
Main
module. - Open the Script view of the script.
- Enjoy the sound of your laptop fans spinning as the scenario service maxes all your CPUs.
- Wait patiently for the message
"Scenario service backend error: BErrorClient (ClientIOError (GRPCIOBadStatusCode StatusDeadlineExceeded (StatusDetails {unStatusDetails = \"Deadline Exceeded\"})))"
appears
module Main where
import Daml.Script
template T
with
p : Party
where
signatory p
key p : Party
maintainer key
let k = key this
t = script do
p <- allocateParty "p"
submit p do
createCmd T with p
Expected behavior
The same thing as if the let clause read let k = p
. Ie the script view appears.
Additional context
Issue Analytics
- State:
- Created a year ago
- Comments:21 (17 by maintainers)
Top Results From Across the Web
infinite loop caused by `isInViewRef` · Issue #572 - GitHub
When calling setRef from this package, it causes an infinite loop if called from ... Callback from IntersectionObserver with a new state.
Read more >MutationObserver create infinite loop when I replace a string ...
The infinite loop is caused by replacing typed / characters with <span>/</span> without turning off the observer first - each replacement ...
Read more >How to solve the React useEffect Hook's infinite loop patterns
Solve the issue of infinite loops when using the useEffect Hook in React to more smoothly utilize the Hook for your app's side...
Read more >Chapter 5 | Python For Everyone | Trinket
If there is no iteration variable, the loop will repeat forever, resulting in an infinite loop. Infinite loops. An endless source of amusement...
Read more >5 useEffect Infinite Loop Patterns | by Naveen DA
In general, infinite loops are considered bad practices. But in some edge cases, you don't have any choice to choose rather than an...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We are not adding warnings for everything that could loop infinitely – this is not possible in theory nor in practice.
I think it’s pretty clear that this is an infinite loop:
And this is an infinite loop that doesn’t look like it:
Unfortunately adding a warning in the latter case is difficult, even for a basic thing like detecting
key this
andsignatory this
, and is at best an approximation.I agree with @akrmn (and others in the language team) that the problem here is the template local let syntax, since it creates a false impression of the semantics. I’m in favor of deprecating it and encouraging people to write global functions instead, where the flow of computation is much more explicit.
OK, I would not try to fix the semantics. Furthermore, lazy semantics only here seems confusing.
I would say to move on with “better error message at runtime and clear documentation of the semantics” to be acceptance criteria to consider this closed.