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

CTFE inbounds-error-messages tweak #84972

Merged
merged 2 commits into from
May 7, 2021
Merged

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented May 6, 2021

  • use CheckInAllocMsg::PointerArithmeticTest for ptr_offset error
  • nicer errors for some null pointer cases

r? @oli-obk

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 6, 2021
@@ -306,6 +306,9 @@ impl fmt::Display for UndefinedBehaviorInfo<'_> {
ptr.alloc_id,
allocation_size.bytes()
),
DanglingIntPointer(_, CheckInAllocMsg::InboundsTest) => {
write!(f, "null pointer is not allowed for this operation")
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This special printing case existed before but at some point turned into dead code which was removed in #84903 -- but the code is good, it just should not be dead. :)

@rust-log-analyzer

This comment has been minimized.

@@ -296,7 +296,7 @@ error[E0080]: could not evaluate static initializer
--> $DIR/ub-wide-ptr.rs:135:5
|
LL | mem::transmute::<_, &dyn Trait>((&92u8, 0usize))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ inbounds test failed: 0x0 is not a valid pointer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ null pointer is not allowed for this operation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish we had more info here, like that this is about a vtable ptr in a wide pointer... but not sure what needs to be done for that. Orthogonal to this PR in any case

@oli-obk
Copy link
Contributor

oli-obk commented May 6, 2021

@bors r+ rollup

@bors
Copy link
Contributor

bors commented May 6, 2021

📌 Commit bcf622b has been approved by oli-obk

@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 May 6, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request May 7, 2021
Rollup of 9 pull requests

Successful merges:

 - rust-lang#84779 (Add support for --test-args to cargotest)
 - rust-lang#84781 (Don't check bootstrap artifacts by default)
 - rust-lang#84787 (bump deps)
 - rust-lang#84815 (Update coverage docs and command line help)
 - rust-lang#84875 (Removes unneeded check of `#[no_coverage]` in mapgen)
 - rust-lang#84897 (Coverage instruments closure bodies in macros (not the macro body))
 - rust-lang#84911 (Retry clang+llvm download)
 - rust-lang#84972 (CTFE inbounds-error-messages tweak)
 - rust-lang#84990 (Sort rustdoc-gui tests)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 4705027 into rust-lang:master May 7, 2021
@rustbot rustbot added this to the 1.54.0 milestone May 7, 2021
@RalfJung RalfJung deleted the null-ptr-msg branch May 7, 2021 12:36
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request May 7, 2021
fix null pointer error messages

I got the `match` in rust-lang#84972 wrong, this fixes that.
Also avoid redundant "inbounds test failed:" prefix.

Should fix rust-lang#85027

r? `@oli-obk`
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request May 7, 2021
fix null pointer error messages

I got the `match` in rust-lang#84972 wrong, this fixes that.
Also avoid redundant "inbounds test failed:" prefix.

Should fix rust-lang#85027

r? `@oli-obk`
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants