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

Rpc_genfake.{gentest,genall}: avoid crash on recursive types #176

Merged
merged 2 commits into from
Sep 25, 2024

Conversation

edwintorok
Copy link
Collaborator

I was trying to define some nice recursive types, but the test generator ended up using a lot of memory, until the system started swapping (and I assume it would've eventually gotten OOM killed).

Attempting to call 'genall' on a recursive type would either result in an OOM kill, because it'd recurse infinitely trying to generate testcases. When recursion depth is negative return the empty list instead of generating recursively and taking the first.

There are more things to fix here, because although the testcase I added here now works, the original type(s) that I created still OOM trying to generate stacks (but stack depth seems fine).

@edwintorok
Copy link
Collaborator Author

I'm opening another PR to fix the remaining problems. Now that OCaml has a Seq module we can limit the number of combinations we generate (instead of m^n) which avoids the other problem I was having.

Attempting to call 'genall' on a recursive type would either result in an OOM kill,
because it'd recurse infinitely trying to generate testcases.
When recursion depth is negative return the empty list instead of generating recursively and taking the first.

Signed-off-by: Edwin Török <[email protected]>
@edwintorok edwintorok merged commit 810d403 into mirage:master Sep 25, 2024
4 checks passed
@edwintorok
Copy link
Collaborator Author

Rebased on top of @Vincent-lau 's PR to make the CI pass, and applied the docstring suggestion. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants