-
Notifications
You must be signed in to change notification settings - Fork 350
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
LSP crash when indexing out of bounds #2252
Comments
While
I'm pretty sure this is a buffer overrun, which is why the behavior is nondeterministic, and why it seems to depend on the index: some indexes have something kind of stringish like this one, while others lead to permissions errors. That said, this is a known issue and expected behavior. Duplicate of #1697. What's happening is that the syntax |
Perhaps two versions of Alternatively, the existence of a |
There are actually two versions of /--
Auxiliary axiom used to implement `sorry`.
The `sorry` term/tactic expands to `sorryAx _ (synthetic := false)`. This is a
proof of anything, which is intended for stubbing out incomplete parts of a
proof while still having a syntactically correct proof skeleton. Lean will give
a warning whenever a proof uses `sorry`, so you aren't likely to miss it, but
you can double check if a theorem depends on `sorry` by using
`#print axioms my_thm` and looking for `sorryAx` in the axiom list.
The `synthetic` flag is false when written explicitly by the user, but it is
set to `true` when a tactic fails to prove a goal, or if there is a type error
in the expression. A synthetic `sorry` acts like a regular one, except that it
suppresses follow-up errors in order to prevent one error from causing a cascade
of other errors because the desired term was not constructed.
-/
@[extern "lean_sorry", never_extract]
axiom sorryAx (α : Sort u) (synthetic := false) : α the kind of sorry that is used in this example is the synthetic one, which I agree have an especially good reason to abort |
I think that because of the possibility of UB, it would be better to be conservative and not allow either kind of |
That makes sense to me, so long as the flag is convenient and discoverable. |
Prerequisites
Description
LSP server crash when indexing arrays out of bounds. Note that I'm using regular indexing
arr[idx]
, not the uncheckedarr[idx]!
version. I believe crashing for unchecked out of bounds indexing is expected behaviour.The behaviour seems to differ between combinations of array length and index.
Steps to Reproduce
Paste into vscode with lean 4 extension running
Expected behavior: [What you expect to happen]
no crash
Actual behavior: [What actually happens]
lsp crashes. It also crashes with
northernTrees[5]
, but curiouslynorthernTrees[6]
gives a type error without crashing, as expected.Reproduces how often: [What percentage of the time does it reproduce?]
100% for this particular case.
At first I thought the rule was
arr[arr.length]
andarr[arr.length+1]
cause crashes and other indices don't. However this doesn't generalize to arrays of different lengths, eg with array of one elementAll indices from 1 to 10 inclusive cause the crash consistently (I didn't keep testing with higher indices)
Versions
Lean (version 4.0.0-nightly-2023-05-22, commit 8d4dd23, Release)
Arch linux (rolling release)
Additional Information
N/A
The text was updated successfully, but these errors were encountered: