Add recursion limit to FFI safety lint#130598
Merged
bors merged 1 commit intorust-lang:masterfrom Sep 21, 2024
Merged
Conversation
Collaborator
|
rustbot has assigned @petrochenkov. Use |
clubby789
requested changes
Sep 20, 2024
1a4286d to
8ea1a53
Compare
compiler-errors
suggested changes
Sep 20, 2024
Fixes stack overflow in the case of recursive types
8ea1a53 to
7160447
Compare
Contributor
compiler-errors
approved these changes
Sep 21, 2024
Contributor
|
It's not totally correct that the type is infinitely recursive; it might just be very large. But whatever, I think having a wrong error message is better than a stack overflow. @bors r+ rollup |
Collaborator
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Sep 21, 2024
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#129718 (add guarantee about remove_dir and remove_file error kinds) - rust-lang#130598 (Add recursion limit to FFI safety lint) - rust-lang#130642 (Pass the current cargo to `run-make` tests) - rust-lang#130644 (Only expect valtree consts in codegen) - rust-lang#130645 (Normalize consts in writeback when GCE is enabled) - rust-lang#130646 (compiler: factor out `OVERFLOWING_LITERALS` impl) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Sep 21, 2024
Rollup merge of rust-lang#130598 - gurry:130310-improper-types-stack-overflow, r=compiler-errors Add recursion limit to FFI safety lint Fixes rust-lang#130310 Now we check against `tcx.recursion_limit()` and raise an error if it the limit is reached instead of overflowing the stack.
| }; | ||
| } | ||
|
|
||
| acc.recursion_depth += 1; |
Contributor
There was a problem hiding this comment.
This was never being decremented.
compiler-errors
added a commit
to compiler-errors/rust
that referenced
this pull request
Sep 24, 2024
…mit, r=jieyouxu Revert "Add recursion limit to FFI safety lint" It's not necessarily clear if warning when we hit the recursion limit is the right thing to do, first of all. **More importantly**, this PR was implemented incorrectly in the first place; it was not decrementing the recursion limit when stepping out of a type, so it would trigger when a ctype has more than RECURSION_LIMIT fields *anywhere* in the type's set of recursively reachable fields. Reverts rust-lang#130598 Reopens rust-lang#130310 Fixes rust-lang#130757
compiler-errors
added a commit
to compiler-errors/rust
that referenced
this pull request
Sep 24, 2024
…mit, r=jieyouxu Revert "Add recursion limit to FFI safety lint" It's not necessarily clear if warning when we hit the recursion limit is the right thing to do, first of all. **More importantly**, this PR was implemented incorrectly in the first place; it was not decrementing the recursion limit when stepping out of a type, so it would trigger when a ctype has more than RECURSION_LIMIT fields *anywhere* in the type's set of recursively reachable fields. Reverts rust-lang#130598 Reopens rust-lang#130310 Fixes rust-lang#130757
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Sep 24, 2024
Rollup merge of rust-lang#130758 - compiler-errors:ctype-recursion-limit, r=jieyouxu Revert "Add recursion limit to FFI safety lint" It's not necessarily clear if warning when we hit the recursion limit is the right thing to do, first of all. **More importantly**, this PR was implemented incorrectly in the first place; it was not decrementing the recursion limit when stepping out of a type, so it would trigger when a ctype has more than RECURSION_LIMIT fields *anywhere* in the type's set of recursively reachable fields. Reverts rust-lang#130598 Reopens rust-lang#130310 Fixes rust-lang#130757
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.
Fixes #130310
Now we check against
tcx.recursion_limit()and raise an error if it the limit is reached instead of overflowing the stack.