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

miri reports undefined behavior #1

Closed
eric-seppanen opened this issue Mar 18, 2024 · 2 comments
Closed

miri reports undefined behavior #1

eric-seppanen opened this issue Mar 18, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@eric-seppanen
Copy link

$ cargo +nightly miri test
...
running 1 test
test src/lib.rs - (line 11) ... FAILED

failures:

---- src/lib.rs - (line 11) stdout ----
Test executable failed (exit status: 1).

stderr:
error: Undefined Behavior: trying to retag from <2453> for SharedReadWrite permission at alloc873[0x0], but that tag does not exist in the borrow stack for this location
   --> /home/eric/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/non_null.rs:401:18
    |
401 |         unsafe { &*self.as_ptr().cast_const() }
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |                  |
    |                  trying to retag from <2453> for SharedReadWrite permission at alloc873[0x0], but that tag does not exist in the borrow stack for this location
    |                  this error occurs as part of retag at alloc873[0x0..0x28]
    |
    = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
    = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
help: <2453> was created by a SharedReadWrite retag at offsets [0x18..0x51]
   --> src/lib.rs:16:1
    |
8   | / executor::run(
9   | | async {
10  | |     let (s, mut r) = multishot::channel();
11  | |
...   |
33  | | }
34  | | );
    | |_^
$ cargo +nightly -V
cargo 1.78.0-nightly (f772ec022 2024-03-01)
@eric-seppanen
Copy link
Author

Looks like this is due to the executor crate; I was able to reproduce it using async_channel also.
richardanaya/executor#13

@sbarral
Copy link
Member

sbarral commented Mar 19, 2024

Thank you very much for the report and for pinning down the cause before I even woke up and started investigating :)
My bad for excluding doctests from the Miri CI checks, I will update the workflow.

@sbarral sbarral added the bug Something isn't working label Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants