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

Do recursive shrinking without recursive function calls #294

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on Jun 12, 2021

  1. impl: do recursive shrinking without recursive fn call

    We try to shrink values recursively, i.e. when a shrunk value witnesses
    a failure, we'd shrink that value further. Previously, this recursion
    would be implemented via actual control flow recursion, i.e. a function
    calling itself. Since the recursion could not be unrolled by the
    compiler, this could result in stack overflows in some situations.
    
    Albeit such an overflow would often hint at a faulty shrinker (e.g. a
    shrinker yielding the original value), the stack overflow could also
    occur in other situations.
    
    This change switches from a recursive control flow to explicitly
    swapping out the shrinking iterator during the iteration.
    neithernut committed Jun 12, 2021
    Configuration menu
    Copy the full SHA
    9ee29bb View commit details
    Browse the repository at this point in the history
  2. impl: move shrinking logic out of inline function

    In the past, shrinking was implemented using recursion in the control
    flow. `shrink_failure` would call itself. That function was introduced
    originally in
    
            5b19e7c
    
    presumably in order to implement recursive shrinking. However, we
    recently choose an approach which would not rely on recursive control
    flow but on swapping out an iterator. Thus, the reason why
    `shrink_failure` existed in the first place doesn't exist any more.
    This change moves the logic in its original place, but also replaces the
    `match` which enclosed the call to `shrink_failure` with an `if`.
    neithernut committed Jun 12, 2021
    Configuration menu
    Copy the full SHA
    61ae277 View commit details
    Browse the repository at this point in the history