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

Strange error message when passing ill-typed code to Miri #458

Closed
RalfJung opened this issue Jan 23, 2019 · 13 comments
Closed

Strange error message when passing ill-typed code to Miri #458

RalfJung opened this issue Jan 23, 2019 · 13 comments
Labels
bug The playground isn't doing what it was intended to help wanted Not immediately going to be prioritized — ask for mentoring instructions!

Comments

@RalfJung
Copy link
Member

This example shows the following error when hitting "Run":

   Compiling playground v0.0.1 (/playground)
error[E0425]: cannot find function `Droppable` in this scope
 --> src/main.rs:2:17
  |
2 |     let mut x = Droppable(0);
  |                 ^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `Droppable` in this scope
 --> src/main.rs:5:19
  |
5 |     unsafe { *p = Droppable(1); } // prints "dropping 0"
  |                   ^^^^^^^^^ not found in this scope

error: aborting due to 2 previous errors

But when I send it to Miri, I get

error[E0460]: found possibly newer version of crate `core` which `unicode_width` depends on
  |
  = note: perhaps that crate needs to be recompiled?
  = note: the following crate versions were found:
          crate `core`: /root/.cache/miri/HOST/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-00869b21179267d6.rlib
          crate `unicode_width`: /playground/target/debug/deps/libunicode_width-f959371afbea1e81.rlib

error: aborting due to previous error
@shepmaster
Copy link
Member

shepmaster commented Jan 23, 2019

found possibly newer version of crate

This is for any usage of Miri on the playground which includes a crate:

fn main() {
    memchr::memchr(0, &[]);
}

This has been present since Miri was introduced on the playground, AFAIR; TBH I assumed that Miri didn't handle crates yet.

@shepmaster
Copy link
Member

I wonder if this shares commonalities with rust-lang/rust#57854, which is a similar "why is an external crate coming into play anyway".

@shepmaster shepmaster added bug The playground isn't doing what it was intended to help wanted Not immediately going to be prioritized — ask for mentoring instructions! labels Jan 23, 2019
@RalfJung
Copy link
Member Author

But my example doesn't use a crate, does it?

Miri works fine with crates locally.

@RalfJung
Copy link
Member Author

How do these other crates get built? Maybe the issue is that they don't get built against Miri's sysroot.

@shepmaster
Copy link
Member

But my example doesn't use a crate, does it?

Right, and neither does the linked issue. Both just have the crates "hanging around".

@shepmaster
Copy link
Member

How do these other crates get built?

Miri starts from the existing nightly container.

The base compiler containers just run cargo build

Maybe the issue is that they don't get built against Miri's sysroot.

Very likely. Does this mean that the Miri container needs to rebuild all the crates? Clippy already does this, so it might be time to reorganize the build process.

@RalfJung
Copy link
Member Author

Does this mean that the Miri container needs to rebuild all the crates?

Yes. They have to be built against the sysroot in ~/.cache/miri/HOST.

@shepmaster
Copy link
Member

They have to be built against the sysroot in ~/.cache/miri/HOST.

What's the invocation for that? You're more familiar with our build process w.r.t. Miri.

@RalfJung
Copy link
Member Author

You have a Cargo.toml will all the deps, right? Doing cargo clean && cargo miri run in that project dir should be sufficient.

@shepmaster
Copy link
Member

cargo clean

Is this required? Docker has additive filesystems, deleting stuff from a previous layer doesn't save any space.

cargo miri run

Presumably with at least a fn main() {}? There is no main.rs or lib.rs inside the container.

@RalfJung
Copy link
Member Author

Without the clean I am worried it will just not do anything as the previously compiled libs are still around.

Yes, having an empty main makes sense (or the command will likely fail -- it did all its work by then, but still, that'd be ugly).

@shepmaster
Copy link
Member

Implicitly fixed by #460 ?

@RalfJung
Copy link
Member Author

Indeed, thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The playground isn't doing what it was intended to help wanted Not immediately going to be prioritized — ask for mentoring instructions!
Projects
None yet
Development

No branches or pull requests

2 participants