Avoid stackoverflow on recursive tail calls #60

Open
opened 2024-01-05 13:52:58 +00:00 by quentin · 0 comments
Owner

Aerogramme has some recursive functions managing user data.
Inputs can be crafted so that Aerogramme will crash.
We can use the tailcall module and rewrite our function a little bit to avoid that.
But sometimes it's not possible to do tailcall optimizations.
We could of course use a stack to rewrite our logic.
However it will make the code harder to read.
So, probably, the right solution would be simply to limit the depth of the recursion.
Putting limits every places we have user data is probably a good idea...

Aerogramme has some recursive functions managing user data. Inputs can be crafted so that Aerogramme will crash. We can use the tailcall module and rewrite our function a little bit to avoid that. But sometimes it's not possible to do tailcall optimizations. We could of course use a stack to rewrite our logic. However it will make the code harder to read. So, probably, the right solution would be simply to limit the depth of the recursion. Putting limits every places we have user data is probably a good idea...
quentin added the
cat
bug
prio
low
labels 2024-01-05 13:52:58 +00:00
quentin changed title from Implement tailcall optimization to Avoid stackoverflow on recursive tail calls 2024-01-05 13:53:38 +00:00
Sign in to join this conversation.
No description provided.