-
Notifications
You must be signed in to change notification settings - Fork 463
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
feat: abstractMVars: do not loop on bad input #4378
Conversation
previously `abstractMVars` would go into a loop on bad input, in particular if an mvar occurs in its own type. While this should never happen in practice and is thus not a problem for our users, it can be quote annoying when one runs into this problem while developing meta code, as the stack overflow means you don’t get your `trace` messages etc. By keeping track of the mvars whose type we are processing we can break the loop. The function is pure, so no `throwError`, but even a `panic!` is going to be somewhat helpful.
Mathlib CI status (docs):
|
@nomeata Let's discuss this PR in our next 1:1. There are many other places in the code that will loop if there are circular assignments at |
Right, this is right now a draft so that I can find my bugs. We talked a bit at the tea time about this, and it seems that the I would find it helpful if the API and it's docs could be improved. In particular a Also note that here it's not a circular assignment but a circular type (the mvar is unassigned, but occurs is in its own type) that cause this to fail baldy. Do the safe functions check for that? |
Not true. If we call
Here is a bad example using
Same example, using
|
We can implement
|
Thanks. Does it also check that the type of the mvar doesn't mention the mvar, possibly indirectly? (I am not 100% certain, but I think I ran into the infinite loop using just (Maybe I misunderstood what Sebastian said about proof irrelevance and mvars. Maybe it's mvars nested inside proofs.) |
Was able to condense it to a mwe at #4405. |
@nomeata This check is not performed. It is a different discussion whether it should be included in
|
I was using (I wonder if I can reproduce it using |
Of course it's totally fair to say that what I am doing here is a bit too obscure (and now that I know what to look out for I am no longer blocked) and we wait to see if others hit the same issue before acting. |
Let's talk about it next time we meet. I would love to see the code and how it happened. |
You were right to ask for better evidence. I didn’t necessarily expect that to be possible, but it is possible to trigger a stack overflows without using the programmatic interface. Added it to #4405 (comment). |
Thanks. I will work on a fix this week for #4405. |
previously
abstractMVars
would go into a loop on bad input, inparticular if an mvar occurs in its own type. While this should never
happen in practice and is thus not a problem for our users, it can be
quote annoying when one runs into this problem while developing meta
code, as the stack overflow means you don’t get your
trace
messagesetc.
By keeping track of the mvars whose type we are processing we can break
the loop. The function is pure, so no
throwError
, but even apanic!
is going to be somewhat helpful.