Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

track call depth separately from loop count in VM #24512

Merged
merged 3 commits into from
Dec 6, 2024

Conversation

metagn
Copy link
Collaborator

@metagn metagn commented Dec 5, 2024

refs #24503, note after merge: closes #23827

Infinite recursions currently are not tracked separately from infinite loops, because they also increase the loop counter. However the max infinite loop count is very high by default (10 million) and does not reliably catch infinite recursions before consuming a lot of memory. So to protect against infinite recursions, we separately track call depth, and add a separate option for the maximum call depth, much lower than the maximum iteration count by default (2000, the same as nimCallDepthLimit).

@metagn metagn changed the title test limiting call depth in VM to 2000 limit call depth by default in VM Dec 5, 2024
@metagn metagn marked this pull request as ready for review December 5, 2024 08:19
@metagn metagn changed the title limit call depth by default in VM track call depth separately from loop count in VM Dec 5, 2024
compiler/commands.nim Outdated Show resolved Hide resolved
@Araq Araq added the merge_when_passes_CI mergeable once green label Dec 6, 2024
@ringabout ringabout merged commit 6f4106b into nim-lang:devel Dec 6, 2024
18 checks passed
Copy link
Contributor

github-actions bot commented Dec 6, 2024

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from 6f4106b

Hint: mm: orc; opt: speed; options: -d:release
178028 lines; 8.872s; 653.562MiB peakmem

narimiran pushed a commit that referenced this pull request Jan 14, 2025
refs #24503

Infinite recursions currently are not tracked separately from infinite
loops, because they also increase the loop counter. However the max
infinite loop count is very high by default (10 million) and does not
reliably catch infinite recursions before consuming a lot of memory. So
to protect against infinite recursions, we separately track call depth,
and add a separate option for the maximum call depth, much lower than
the maximum iteration count by default (2000, the same as
`nimCallDepthLimit`).

---------

Co-authored-by: Andreas Rumpf <[email protected]>
(cherry picked from commit 6f4106b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge_when_passes_CI mergeable once green
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cyclic proc calls causes infinite memory usage
3 participants