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

bug: stack strategy can overflow the stack #699

Closed
obatirou opened this issue Feb 7, 2025 · 2 comments · Fixed by #779
Closed

bug: stack strategy can overflow the stack #699

obatirou opened this issue Feb 7, 2025 · 2 comments · Fixed by #779
Assignees

Comments

@obatirou
Copy link
Contributor

obatirou commented Feb 7, 2025

In some strategy, elements are manually pushed on the stack. But it can already be 1024 element and raise a StackOverflowError.

By trying to raise the error (by trying to generate a stack with 1024, hypothesis raise a FailedHealthCheck

    @given(evm=arithmetic_tests_strategy)
>   def test_add(self, cairo_run, evm: Evm):
E   hypothesis.errors.FailedHealthCheck: The smallest natural example for your test is extremely large. This makes it difficult for Hypothesis to generate good examples, especially when trying to reduce failing ones at the end. Consider reducing the size of your data if it is of a fixed size. You could also fix this by improving how your data shrinks (see https://hypothesis.readthedocs.io/en/latest/data.html#shrinking for details), or by introducing default values inside your strategy. e.g. could you replace some arguments with their defaults by using one_of(none(), some_complex_strategy)?
E   See https://hypothesis.readthedocs.io/en/latest/healthchecks.html for more information about this. If you want to disable just this health check, add HealthCheck.large_base_example to the suppress_health_check settings for this test.

It seems then that the case of a stack with 1024 is never generated by hypothesis

@obatirou obatirou added this to Keth Feb 7, 2025
@obatirou obatirou converted this from a draft issue Feb 7, 2025
@obatirou obatirou changed the title bug: strategy can overflow the stack bug: stack strategy can overflow the stack Feb 7, 2025
@obatirou obatirou moved this from Todo to Backlog in Keth Feb 7, 2025
@Eikix
Copy link
Member

Eikix commented Feb 10, 2025

strat: add a function in arg_gen stack to push_or_replace instead of push to prevent overflow when not desired

@Eikix Eikix moved this from Backlog to Todo in Keth Feb 10, 2025
@Eikix Eikix added this to the EELS migration milestone Feb 10, 2025
@TobieTom
Copy link

Hola. I'm Tobias and I'm new to the space. I've already contributed to some projects and would like to add this to my pool of experience plus I recently learned rust and cairo

@obatirou obatirou moved this from Todo to In progress in Keth Feb 12, 2025
@obatirou obatirou self-assigned this Feb 12, 2025
Eikix added a commit that referenced this issue Feb 12, 2025
@github-project-automation github-project-automation bot moved this from In progress to Done in Keth Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants