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

normalizer: avoid possible infinite loop on maybe_unfold_head #3021

Merged
merged 3 commits into from
Aug 17, 2023

Conversation

mtzguido
Copy link
Member

No description provided.

@mtzguido
Copy link
Member Author

Needed this to avoid a stack overflow on a Pulse rewrite. @aseemr does it look sensible to you?

@aseemr
Copy link
Collaborator

aseemr commented Aug 16, 2023

Hi Guido, looks reasonable to me. But if it is an fv or uinst node, wouldn't it match the cases before? What is the example term that loops?

@mtzguido
Copy link
Member Author

The example I ran into was just maybe_unfold_head being called with a Tm_name. So it tries to split into head+args, the args are empty, and recurses on the head infinitely.

So this detects the empty args case to not make a recursive call and just tries to unfold the thing.

There's also he choice of calling maybe_unfold_head_fv on the term instead of just saying None, which I should have explained sorry. I think if the term is something like M.f <: ty then it will not match the previous two cases, and leftmost_head_and_args (which unascribes/unmetas) will return (M.f, []), but we should still try to unfold M.f. We could add a check here to only call maybe_unfold_head_fv on Tm_fvar/Tm_uinst, but since is the only client I thought it's just easier to remove the failwith and return None inside that function.

@mtzguido mtzguido enabled auto-merge August 17, 2023 15:42
@mtzguido mtzguido merged commit 05296a3 into FStarLang:master Aug 17, 2023
@mtzguido mtzguido deleted the maybe-unfold-stackoverflow branch August 17, 2023 15:44
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