Skip to content

Improve miri's error reporting in check_in_alloc #57128

Closed
@RalfJung

Description

@RalfJung
Member

The check_in_alloc function currently takes a InboundsCheck for error reporting purposes. That's suboptimal for two reasons: (a) passing InboundsCheck::Live/MaybeDead sounds like it would affect the check that is performed, but it does not; and (b) the error still doesn't actually say what we tried to do with this pointer (access memory, in-bounds arithmetic, pointer equality test, ...).

The InboundsCheck argument should be replaced by something else, and that something else should also be put into the PointerOutOfBounds variant of EvalErrorKind. That could either be an &'static str or a more informative enum. I'd probably start with the string, since it seems unlikely we will want to use this for anything but displaying errors to the user, and it seems okay to not be able to use format!.

Cc @oli-obk

Activity

added
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)
on Dec 26, 2018
FrankSD

FrankSD commented on Dec 30, 2018

@FrankSD

Can i please take this up?I am a first timer contributor

FrankSD

FrankSD commented on Dec 30, 2018

@FrankSD

I just forked and cloned rust-lang project on my local but my local branch folder rust/src/librustc/mir/interpret/ is missing pointer.rs and allocation.rs files.The pointer.rs file does contain the check_in_alloc function.It seems i am missing something basic here....my understanding all the code in the current master are uptodate.I clone the current master branch

RalfJung

RalfJung commented on Dec 30, 2018

@RalfJung
MemberAuthor

@FrankSD sure, you can give it a try. Let's see if we can start by getting Rust to compile on your system :)

my local branch folder rust/src/librustc/mir/interpret/ is missing pointer.rs and allocation.rs files

What does git log say is the latest commit?

Also, did you maybe accidentally look into src/librustc_mir/interpret? Mind the _ vs /.

If you are on Linux/macOS, you can always do find -name pointer.rs:

$ find -name pointer.rs
./src/librustc/mir/interpret/pointer.rs
FrankSD

FrankSD commented on Jan 1, 2019

@FrankSD

git log last commit:

 frank@frank-desktop ~/new-rust/rust $ git log
commit caed80ba4ba8d9f4d3fa8aa9af6c4092d779cd9d
Merge: ede5551 002f03b
Author: bors <bors@rust-lang.org>
Date:   Sun Aug 26 09:41:28 2018 +0000

   Auto merge of #53629 - nnethercote:lazier-SparseBitMatrix, r=nikomatsakis
   
   Lazier sparse bit matrix
   
   A small NLL win.
   
   r? @nikomatsakis

And find -name pointer.rs doesnt return anything

rank@frank-desktop ~/new-rust/rust $ find -name pointer.rs

RalfJung

RalfJung commented on Jan 1, 2019

@RalfJung
MemberAuthor

Date: Sun Aug 26 09:41:28 2018 +0000

Your compiler is 4 months outdated. Try getting the latest version, it will have the files you are missing.

Maybe what happened is that you forked rustc 4 months ago, and then you cloned your fork. Forks don't get updated when the main rsutc repo moves along. You should always clone the main rustc repo, and only push to your fork for creating PRs.

FrankSD

FrankSD commented on Jan 1, 2019

@FrankSD

Thank you@RalfJung....that make sense

FrankSD

FrankSD commented on Jan 2, 2019

@FrankSD

It compiles fine and all the files i can see now....but it fails when trying to install. I have resolved most of the issues but trying to install bootstrap,did fails with :-
"

 "failed to run: /home/frank/new-rust/rust/build/bootstrap/debug/bootstrap install
Build completed unsuccessfully in 0:00:01
FrankSD

FrankSD commented on Jan 3, 2019

@FrankSD

I have resolved the build issue.I am starting to check the Issue

RalfJung

RalfJung commented on Jan 3, 2019

@RalfJung
MemberAuthor

Notice also that there is no reason to install your locally built Rust (I never did that, didn't even know it is possible). Why did you even want to do that?

FrankSD

FrankSD commented on Jan 3, 2019

@FrankSD

I was following the official Rust Contribution guide where it mention do
x.py build && x.py install .

RalfJung

RalfJung commented on Jan 3, 2019

@RalfJung
MemberAuthor

Could you send me the URL to that? At https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md it doesn't say anything about x.py install.

FrankSD

FrankSD commented on Jan 3, 2019

@FrankSD

Sorry i think this was from the Readme.md https://github.com/rust-lang/rust/blob/master/README.md

28 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @RalfJung@oli-obk@FrankSD@LooMaclin@saleemjaffer

      Issue actions

        Improve miri's error reporting in check_in_alloc · Issue #57128 · rust-lang/rust