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

interpret: on a signed deref check, mention the right pointer in the error #128482

Merged
merged 3 commits into from
Aug 1, 2024

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Aug 1, 2024

When a negative offset (like ptr.offset(-10)) goes out-of-bounds, we currently show an error saying that we expect the resulting pointer to be inbounds for 10 bytes. That's confusing, so this PR makes it so that instead we say that we expect the original pointer ptr to have 10 bytes to the left.

I also realized I can simplify the pointer arithmetic logic and handling of "staying inbounds of a target usize" quite a bit; the second commit does that.

@rustbot
Copy link
Collaborator

rustbot commented Aug 1, 2024

r? @wesleywiser

rustbot has assigned @wesleywiser.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 1, 2024
@rustbot
Copy link
Collaborator

rustbot commented Aug 1, 2024

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

The Miri subtree was changed

cc @rust-lang/miri

@RalfJung RalfJung changed the title on a signed deref check, mention the right pointer in the error interpret: on a signed deref check, mention the right pointer in the error Aug 1, 2024
@rust-log-analyzer

This comment has been minimized.

@oli-obk
Copy link
Contributor

oli-obk commented Aug 1, 2024

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 1, 2024

📌 Commit e4bb248 has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 1, 2024
@rust-log-analyzer

This comment has been minimized.

@oli-obk
Copy link
Contributor

oli-obk commented Aug 1, 2024

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 1, 2024
@oli-obk
Copy link
Contributor

oli-obk commented Aug 1, 2024

r=me with CI happy

@RalfJung
Copy link
Member Author

RalfJung commented Aug 1, 2024

@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Aug 1, 2024

📌 Commit 0f15f05 has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 1, 2024
@rust-log-analyzer

This comment has been minimized.

@RalfJung
Copy link
Member Author

RalfJung commented Aug 1, 2024

Argh.
@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 1, 2024
@RalfJung
Copy link
Member Author

RalfJung commented Aug 1, 2024

@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Aug 1, 2024

📌 Commit db1652e has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 1, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 1, 2024
interpret: on a signed deref check, mention the right pointer in the error

When a negative offset (like `ptr.offset(-10)`) goes out-of-bounds, we currently show an error saying that we expect the *resulting* pointer to be inbounds for 10 bytes. That's confusing, so this PR makes it so that instead we say that we expect the *original* pointer `ptr` to have 10 bytes *to the left*.

I also realized I can simplify the pointer arithmetic logic and handling of "staying inbounds of a target `usize`" quite a bit; the second commit does that.
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 1, 2024
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#127490 (Add target page for riscv64gc-unknown-linux-gnu)
 - rust-lang#128433 (fix(hermit): `deny(unsafe_op_in_unsafe_fn)`)
 - rust-lang#128482 (interpret: on a signed deref check, mention the right pointer in the error)
 - rust-lang#128496 (Fix removed `box_syntax` diagnostic if source isn't available)
 - rust-lang#128497 (fix dropck documentation for `[T;0]` special-case)
 - rust-lang#128499 (chore: refactor backtrace formatting)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 8671b0b into rust-lang:master Aug 1, 2024
6 checks passed
@rustbot rustbot added this to the 1.82.0 milestone Aug 1, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Aug 1, 2024
Rollup merge of rust-lang#128482 - RalfJung:ptr-signed-offset, r=oli-obk

interpret: on a signed deref check, mention the right pointer in the error

When a negative offset (like `ptr.offset(-10)`) goes out-of-bounds, we currently show an error saying that we expect the *resulting* pointer to be inbounds for 10 bytes. That's confusing, so this PR makes it so that instead we say that we expect the *original* pointer `ptr` to have 10 bytes *to the left*.

I also realized I can simplify the pointer arithmetic logic and handling of "staying inbounds of a target `usize`" quite a bit; the second commit does that.
@RalfJung RalfJung deleted the ptr-signed-offset branch August 2, 2024 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants