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

ICE when setting -Zmiri-track-pointer-tag #2709

Closed
RalfJung opened this issue Dec 2, 2022 · 2 comments · Fixed by #2710
Closed

ICE when setting -Zmiri-track-pointer-tag #2709

RalfJung opened this issue Dec 2, 2022 · 2 comments · Fixed by #2710

Comments

@RalfJung
Copy link
Member

RalfJung commented Dec 2, 2022

Trying to debug rust-lang/futures-rs#2669 with MIRIFLAGS="-Zmiri-track-pointer-tag=12798" cargo miri run, Miri ICEs:

note: tracking was triggered
  --> /home/r/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/futures-util-0.3.25/src/sink/feed.rs:20:16
   |
20 |         Feed { sink, item: Some(item) }
   |                ^^^^ created tag 12798 for unique reference (pointee type futures::futures_channel::mpsc::Sender<u32>) at alloc4773[0x10..0x28] derived from <12797>
   |
   = note: inside `futures::sink::Feed::<'_, futures::futures_channel::mpsc::Sender<u32>, u32>::new` at /home/r/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/futures-util-0.3.25/src/sink/feed.rs:20:16
   = note: inside `futures::sink::Send::<'_, futures::futures_channel::mpsc::Sender<u32>, u32>::new` at /home/r/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/futures-util-0.3.25/src/sink/send.rs:20:22
   = note: inside `<futures::futures_channel::mpsc::Sender<u32> as futures::SinkExt<u32>>::send` at /home/r/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/futures-util-0.3.25/src/sink/mod.rs:224:53
note: inside closure at src/main.rs:6:9
  --> src/main.rs:6:9
   |
6  |         sender.send(n - x).await.unwrap();
   |         ^^^^^^^^^^^^^^^^^^
   = note: inside closure at /home/r/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/futures-executor-0.3.25/src/local_pool.rs:317:23
   = note: inside closure at /home/r/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/futures-executor-0.3.25/src/local_pool.rs:90:37
   = note: inside `std::thread::LocalKey::<std::sync::Arc<futures_executor::local_pool::ThreadNotify>>::try_with::<[closure@futures_executor::local_pool::run_executor<(), [closure@futures::executor::block_on<impl Future<Output = ()>>::{closure#0}]>::{closure#0}], ()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/thread/local.rs:446:16
   = note: inside `std::thread::LocalKey::<std::sync::Arc<futures_executor::local_pool::ThreadNotify>>::with::<[closure@futures_executor::local_pool::run_executor<(), [closure@futures::executor::block_on<impl Future<Output = ()>>::{closure#0}]>::{closure#0}], ()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/thread/local.rs:422:9
   = note: inside `futures_executor::local_pool::run_executor::<(), [closure@futures::executor::block_on<impl Future<Output = ()>>::{closure#0}]>` at /home/r/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/futures-executor-0.3.25/src/local_pool.rs:86:5
   = note: inside `futures::executor::block_on::<impl Future<Output = ()>>` at /home/r/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/futures-executor-0.3.25/src/local_pool.rs:317:5
note: inside closure at src/main.rs:12:35
  --> src/main.rs:12:35
   |
12 |     let t = thread::spawn(move || block_on(send_sequence(20, tx)));
   |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

thread '<unnamed>' panicked at 'Only SharedReadOnly and Unique retags can pop tags', src/stacked_borrows/diagnostics.rs:469:25
stack backtrace:
   0:     0x7f0dd7b665fa - std::backtrace_rs::backtrace::libunwind::trace::h1dd518344624153d
                               at /rustc/454784afba5bf35b5ff14ada0e31265ad1d75e73/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f0dd7b665fa - std::backtrace_rs::backtrace::trace_unsynchronized::he918b797e698b8a3
                               at /rustc/454784afba5bf35b5ff14ada0e31265ad1d75e73/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f0dd7b665fa - std::sys_common::backtrace::_print_fmt::hd34807dd87162202
                               at /rustc/454784afba5bf35b5ff14ada0e31265ad1d75e73/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f0dd7b665fa - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd03d604e5a5ca9ff
                               at /rustc/454784afba5bf35b5ff14ada0e31265ad1d75e73/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f0dd7bc91ee - core::fmt::write::hc7296a8ce92145b7
                               at /rustc/454784afba5bf35b5ff14ada0e31265ad1d75e73/library/core/src/fmt/mod.rs:1208:17
   5:     0x7f0dd7b56b15 - std::io::Write::write_fmt::ha8f348cf2ca519e6
                               at /rustc/454784afba5bf35b5ff14ada0e31265ad1d75e73/library/std/src/io/mod.rs:1682:15
   6:     0x7f0dd7b663c5 - std::sys_common::backtrace::_print::h4509d7b653ffa042
                               at /rustc/454784afba5bf35b5ff14ada0e31265ad1d75e73/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f0dd7b663c5 - std::sys_common::backtrace::print::ha73fd42e1f36fda3
                               at /rustc/454784afba5bf35b5ff14ada0e31265ad1d75e73/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f0dd7b690ef - std::panicking::default_hook::{{closure}}::h41b74867f73477b4
                               at /rustc/454784afba5bf35b5ff14ada0e31265ad1d75e73/library/std/src/panicking.rs:267:22
   9:     0x7f0dd7b68e2b - std::panicking::default_hook::h7e5015f093137304
                               at /rustc/454784afba5bf35b5ff14ada0e31265ad1d75e73/library/std/src/panicking.rs:286:9
  10:     0x7f0dd7b6990c - std::panicking::rust_panic_with_hook::h88b314422a50a805
                               at /rustc/454784afba5bf35b5ff14ada0e31265ad1d75e73/library/std/src/panicking.rs:688:13
  11:     0x7f0dd7b69662 - std::panicking::begin_panic_handler::{{closure}}::h23d4285fcc69a858
                               at /rustc/454784afba5bf35b5ff14ada0e31265ad1d75e73/library/std/src/panicking.rs:577:13
  12:     0x7f0dd7b66aac - std::sys_common::backtrace::__rust_end_short_backtrace::h7a0adf79e578b8b5
                               at /rustc/454784afba5bf35b5ff14ada0e31265ad1d75e73/library/std/src/sys_common/backtrace.rs:137:18
  13:     0x7f0dd7b693b2 - rust_begin_unwind
                               at /rustc/454784afba5bf35b5ff14ada0e31265ad1d75e73/library/std/src/panicking.rs:575:5
  14:     0x7f0dd7bc5c03 - core::panicking::panic_fmt::h9e3943e295010766
                               at /rustc/454784afba5bf35b5ff14ada0e31265ad1d75e73/library/core/src/panicking.rs:65:14
  15:     0x55857e01f0d5 - miri::stacked_borrows::diagnostics::DiagnosticCx::check_tracked_tag_popped::h1287019500a3574e
  16:     0x55857e03a890 - miri::stacked_borrows::<impl miri::stacked_borrows::stack::Stack>::item_invalidated::he4648ed37cc5a5d4
  17:     0x55857e03ada9 - miri::stacked_borrows::<impl miri::stacked_borrows::stack::Stack>::access::h3c5987715865ada3
  18:     0x55857e03b345 - miri::stacked_borrows::<impl miri::stacked_borrows::stack::Stack>::grant::hd4e52a3e152d1a16
  19:     0x55857dffa372 - miri::stacked_borrows::Stacks::for_each::h04e7eb8f2a9bfe39
  20:     0x55857e0f5db9 - miri::stacked_borrows::EvalContextPrivExt::retag_reference::h65392b4921736fdc
  21:     0x55857dffb540 - <miri::stacked_borrows::EvalContextExt::retag::RetagVisitor as rustc_const_eval::interpret::visitor::MutValueVisitor<miri::machine::MiriMachine>>::visit_value::hb8bc38641e668524
  22:     0x55857e07218d - rustc_const_eval::interpret::step::<impl rustc_const_eval::interpret::eval_context::InterpCx<M>>::statement::h22b237c9c4566bb9
  23:     0x55857e09642d - miri::concurrency::thread::EvalContextExt::run_threads::h1cabd645afd817e6
  24:     0x55857e01addd - miri::eval::eval_entry::hf9d458254009ebf8
  25:     0x55857df6bcc4 - rustc_interface::passes::QueryContext::enter::h1ed6ad35f62a1d6e
  26:     0x55857df70b73 - <miri::MiriCompilerCalls as rustc_driver::Callbacks>::after_analysis::h5a9c0fdbb1274a39
  27:     0x7f0dda0f2c4b - <rustc_interface[dd2174059dcac912]::interface::Compiler>::enter::<rustc_driver[72ce08a8917da1fb]::run_compiler::{closure#1}::{closure#2}, core[6b2c651716d4fca9]::result::Result<core[6b2c651716d4fca9]::option::Option<rustc_interface[dd2174059dcac912]::queries::Linker>, rustc_errors[882350c36121b4b0]::ErrorGuaranteed>>
  28:     0x7f0dda0edc48 - rustc_span[fc55d58d8aaf47cd]::with_source_map::<core[6b2c651716d4fca9]::result::Result<(), rustc_errors[882350c36121b4b0]::ErrorGuaranteed>, rustc_interface[dd2174059dcac912]::interface::run_compiler<core[6b2c651716d4fca9]::result::Result<(), rustc_errors[882350c36121b4b0]::ErrorGuaranteed>, rustc_driver[72ce08a8917da1fb]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  29:     0x7f0dda0ed735 - <scoped_tls[f250f949f4492114]::ScopedKey<rustc_span[fc55d58d8aaf47cd]::SessionGlobals>>::set::<rustc_interface[dd2174059dcac912]::interface::run_compiler<core[6b2c651716d4fca9]::result::Result<(), rustc_errors[882350c36121b4b0]::ErrorGuaranteed>, rustc_driver[72ce08a8917da1fb]::run_compiler::{closure#1}>::{closure#0}, core[6b2c651716d4fca9]::result::Result<(), rustc_errors[882350c36121b4b0]::ErrorGuaranteed>>
  30:     0x7f0dda0ecd22 - std[20563ae6fe1725c8]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[dd2174059dcac912]::util::run_in_thread_pool_with_globals<rustc_interface[dd2174059dcac912]::interface::run_compiler<core[6b2c651716d4fca9]::result::Result<(), rustc_errors[882350c36121b4b0]::ErrorGuaranteed>, rustc_driver[72ce08a8917da1fb]::run_compiler::{closure#1}>::{closure#0}, core[6b2c651716d4fca9]::result::Result<(), rustc_errors[882350c36121b4b0]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6b2c651716d4fca9]::result::Result<(), rustc_errors[882350c36121b4b0]::ErrorGuaranteed>>
  31:     0x7f0dda0eca38 - <<std[20563ae6fe1725c8]::thread::Builder>::spawn_unchecked_<rustc_interface[dd2174059dcac912]::util::run_in_thread_pool_with_globals<rustc_interface[dd2174059dcac912]::interface::run_compiler<core[6b2c651716d4fca9]::result::Result<(), rustc_errors[882350c36121b4b0]::ErrorGuaranteed>, rustc_driver[72ce08a8917da1fb]::run_compiler::{closure#1}>::{closure#0}, core[6b2c651716d4fca9]::result::Result<(), rustc_errors[882350c36121b4b0]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6b2c651716d4fca9]::result::Result<(), rustc_errors[882350c36121b4b0]::ErrorGuaranteed>>::{closure#1} as core[6b2c651716d4fca9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  32:     0x7f0ddbc4f2c3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hce4e75902a760e01
                               at /rustc/454784afba5bf35b5ff14ada0e31265ad1d75e73/library/alloc/src/boxed.rs:2000:9
  33:     0x7f0ddbc4f2c3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3137a6d583991f5b
                               at /rustc/454784afba5bf35b5ff14ada0e31265ad1d75e73/library/alloc/src/boxed.rs:2000:9
  34:     0x7f0ddbc4f2c3 - std::sys::unix::thread::Thread::new::thread_start::hf39f51d3bdf8251a
                               at /rustc/454784afba5bf35b5ff14ada0e31265ad1d75e73/library/std/src/sys/unix/thread.rs:108:17
  35:     0x7f0dd782ffd4 - start_thread
                               at ./nptl/./nptl/pthread_create.c:442:8
  36:     0x7f0dd78b066c - __GI___clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  37:                0x0 - <unknown>

Miri caused an ICE during evaluation. Here's the interpreter backtrace at the time of the panic:
note: the place in the program where the ICE was triggered
   --> /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/ops/deref.rs:183:9
    |
183 |         *self
    |         ^^^^^
    |
    = note: inside `<&mut impl Future<Output = ()> as std::ops::DerefMut>::deref_mut` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/ops/deref.rs:183:9
    = note: inside `std::pin::Pin::<&mut impl Future<Output = ()>>::as_mut` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/pin.rs:703:42
    = note: inside closure at /home/r/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/futures-executor-0.3.25/src/local_pool.rs:317:23
    = note: inside closure at /home/r/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/futures-executor-0.3.25/src/local_pool.rs:90:37
    = note: inside `std::thread::LocalKey::<std::sync::Arc<futures_executor::local_pool::ThreadNotify>>::try_with::<[closure@futures_executor::local_pool::run_executor<(), [closure@futures::executor::block_on<impl Future<Output = ()>>::{closure#0}]>::{closure#0}], ()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/thread/local.rs:446:16
    = note: inside `std::thread::LocalKey::<std::sync::Arc<futures_executor::local_pool::ThreadNotify>>::with::<[closure@futures_executor::local_pool::run_executor<(), [closure@futures::executor::block_on<impl Future<Output = ()>>::{closure#0}]>::{closure#0}], ()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/thread/local.rs:422:9
    = note: inside `futures_executor::local_pool::run_executor::<(), [closure@futures::executor::block_on<impl Future<Output = ()>>::{closure#0}]>` at /home/r/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/futures-executor-0.3.25/src/local_pool.rs:86:5
    = note: inside `futures::executor::block_on::<impl Future<Output = ()>>` at /home/r/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/futures-executor-0.3.25/src/local_pool.rs:317:5
note: inside closure at src/main.rs:12:35
   --> src/main.rs:12:35
    |
12  |     let t = thread::spawn(move || block_on(send_sequence(20, tx)));
    |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: inside `std::sys_common::backtrace::__rust_begin_short_backtrace::<[closure@src/main.rs:12:27: 12:34], ()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:121:18
    = note: inside closure at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/thread/mod.rs:550:17
    = note: inside `<std::panic::AssertUnwindSafe<[closure@std::thread::Builder::spawn_unchecked_<'_, '_, [closure@src/main.rs:12:27: 12:34], ()>::{closure#1}::{closure#0}]> as std::ops::FnOnce<()>>::call_once` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:271:9
    = note: inside `std::panicking::r#try::do_call::<std::panic::AssertUnwindSafe<[closure@std::thread::Builder::spawn_unchecked_<'_, '_, [closure@src/main.rs:12:27: 12:34], ()>::{closure#1}::{closure#0}]>, ()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:483:40
    = note: inside `std::panicking::r#try::<(), std::panic::AssertUnwindSafe<[closure@std::thread::Builder::spawn_unchecked_<'_, '_, [closure@src/main.rs:12:27: 12:34], ()>::{closure#1}::{closure#0}]>>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:447:19
    = note: inside `std::panic::catch_unwind::<std::panic::AssertUnwindSafe<[closure@std::thread::Builder::spawn_unchecked_<'_, '_, [closure@src/main.rs:12:27: 12:34], ()>::{closure#1}::{closure#0}]>, ()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panic.rs:137:14
    = note: inside closure at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/thread/mod.rs:549:30
    = note: inside `<[closure@std::thread::Builder::spawn_unchecked_<'_, '_, [closure@src/main.rs:12:27: 12:34], ()>::{closure#1}] as std::ops::FnOnce<()>>::call_once - shim(vtable)` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/ops/function.rs:507:5
    = note: inside `<std::boxed::Box<dyn std::ops::FnOnce()> as std::ops::FnOnce<()>>::call_once` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/alloc/src/boxed.rs:2000:9
    = note: inside `<std::boxed::Box<std::boxed::Box<dyn std::ops::FnOnce()>> as std::ops::FnOnce<()>>::call_once` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/alloc/src/boxed.rs:2000:9
    = note: inside `std::sys::unix::thread::Thread::new::thread_start` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/sys/unix/thread.rs:108:17

Maybe we should remove panics from the diagnostic code, and just make it silent in that case? It is quite frustrating when diagnostic code prevents one from diagnosing an issue.^^

Cc @saethlin

bors added a commit that referenced this issue Dec 2, 2022
@saethlin
Copy link
Member

saethlin commented Dec 2, 2022

Maybe we should remove panics from the diagnostic code

So long as we have another way for the code to unambiguously complain that it is broken, yes. The only alternative I had in mind is letting the diagnostics be wrong, and if it's a choice between a wrong diagnostic and an ICE, I lean towards the ICE. I would love a third option.

@saethlin
Copy link
Member

saethlin commented Dec 2, 2022

Also I should look into that bug, if it's a case where pointer tracking is still useful...

@bors bors closed this as completed in 63b6395 Dec 2, 2022
RalfJung pushed a commit to RalfJung/rust that referenced this issue Dec 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants