-
Notifications
You must be signed in to change notification settings - Fork 27
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
What is the best way to avoid stack overflows with recursive generators? #58
Comments
Can you post the generator in question? 'pulling constants out of choose' is something Crowbar does internally. When a recursive generator is building too large a structure, it tries to halt the recursion by picking cases in a |
Here's the generator (out of context)
I see now that it doesn't have any explicit constants in it, but it would be easy for me to manually transform the |
Right, adding even a single constant to this should fix the problem. With this generator, when Crowbar runs out of space it has no idea how to stop, since all of the options are |
Excellent, thanks! Would you be amenable to a PR that prints a warning if |
Also, while I'm looking, what's the deal with this function that always returns false? Line 237 in c8209e7
|
I just had a chance to try this again with the fix of adding at least one constant inside the choose, but I still get stack overflows after a few million executions. Here's the new generator
|
(found some time to hack on this again...) Turns out I broke the Something to detect this case would definitely be good. |
I'm new to the library, and I tried reading through the source code and all existing open and closed issues and PRs, but I couldn't find any guidance to this.
I have a simple recursive generator for a tree datatype that causes stack overflows when tested extensively (on the order of millions of executions). What should I do to work around this? (By the way, I tried using
lazy
/unlazy
andfix
, but the problem occurs with both.)I saw some reference to a trick where you "pull constants out of the choose", but I couldn't quite figure out what that meant or how to do it.
Thanks!
The text was updated successfully, but these errors were encountered: