fix: kernel: move level parameter count and thm-is-prop checks for robustness#12817
Merged
fix: kernel: move level parameter count and thm-is-prop checks for robustness#12817
Conversation
The kernel would crash (access uninitialized memory) when `is_delta` succeeded for a constant whose supplied universe-level count did not match its declaration's level-parameter count. `unfold_definition_core` had the count check, so it returned `none_expr()` in that case. Call sites in `lazy_delta_reduction_step` unconditionally dereferenced that result, causing undefined behaviour (garbled error or SIGSEGV). Fix: add the level-parameter-count check to `is_delta` and remove the now- redundant check from `unfold_definition_core`. This establishes the invariant: if `is_delta` succeeds then `unfold_definition` will also succeed. Add a regression test from the fuzzer-discovered reproducer in #10577. Co-authored-by: nomeata <148037+nomeata@users.noreply.github.com>
Co-authored-by: nomeata <148037+nomeata@users.noreply.github.com>
…o .gitignore Co-authored-by: nomeata <148037+nomeata@users.noreply.github.com>
Co-authored-by: nomeata <148037+nomeata@users.noreply.github.com>
…or robustness Co-authored-by: nomeata <148037+nomeata@users.noreply.github.com>
Co-authored-by: nomeata <148037+nomeata@users.noreply.github.com>
|
Mathlib CI status (docs):
|
Collaborator
|
Reference manual CI status:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR moves the universe-level-count check from
unfold_definition_coreintois_delta, establishing the invariant that ifis_deltasucceeds thenunfold_definitionalso succeeds. This prevents a crash (SIGSEGV or garbled error) that occurred when call sites inlazy_delta_reduction_stepunconditionally dereferenced the result ofunfold_definitioneven on a level-parameter-count mismatch.Additionally, moves the
is_propcheck for theorem types inadd_theoremto occur aftercheck_constant_val, so the type is verified to be well-formed beforeis_propevaluates it. This preventsis_propfrom being called on an ill-typed term when a malformed theorem declaration is supplied.Fixes #10577.