facebookexperimental/MIRAI

Assertion failure when checking a program

osa1 opened this issue · 1 comments

osa1 commented

Issue

mirai panics (in rustc code) when checking a crate of mine: https://github.com/osa1/tiny

Steps to Reproduce

Just build using the described workflow in MIRAI README file.

Expected Behavior

I'd expect the build to finish without panics.

Actual Results

It panics. Error with backtrace: (I just realized there are more panics if I let the build finish, I included all below)

Build failures, with backtraces
   Compiling nix v0.19.1
   Compiling syn v1.0.60
   Compiling sct v0.6.0
   Compiling tokio v0.3.7
   Compiling webpki v0.21.4
   Compiling clap v2.33.3
   Compiling rand v0.8.3
thread 'rustc' panicked at 'assertion failed: `(left != right)`
  left: `0`,
 right: `0`: you should never look at the bits of a ZST', /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/compiler/rustc_middle/src/ty/consts/int.rs:234:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/library/core/src/panicking.rs:92:14
   2: rustc_middle::ty::consts::int::ScalarInt::to_bits
             at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/compiler/rustc_middle/src/ty/consts/int.rs:234:9
   3: mirai::block_visitor::BlockVisitor<E>::get_enum_variant_as_constant
             at /home/omer/rust/MIRAI/checker/src/block_visitor.rs:2274:24
   4: mirai::block_visitor::BlockVisitor<E>::visit_constant
             at /home/omer/rust/MIRAI/checker/src/block_visitor.rs:2168:24
   5: mirai::block_visitor::BlockVisitor<E>::visit_use
             at /home/omer/rust/MIRAI/checker/src/block_visitor.rs:1363:35
   6: mirai::block_visitor::BlockVisitor<E>::visit_rvalue
             at /home/omer/rust/MIRAI/checker/src/block_visitor.rs:1302:17
   7: mirai::block_visitor::BlockVisitor<E>::visit_assign
             at /home/omer/rust/MIRAI/checker/src/block_visitor.rs:140:9
   8: mirai::block_visitor::BlockVisitor<E>::visit_statement
             at /home/omer/rust/MIRAI/checker/src/block_visitor.rs:107:17
   9: mirai::block_visitor::BlockVisitor<E>::visit_basic_block
             at /home/omer/rust/MIRAI/checker/src/block_visitor.rs:80:17
  10: mirai::fixed_point_visitor::FixedPointVisitor<E>::visit_basic_block
             at /home/omer/rust/MIRAI/checker/src/fixed_point_visitor.rs:131:9
  11: mirai::fixed_point_visitor::FixedPointVisitor<E>::visit_blocks
             at /home/omer/rust/MIRAI/checker/src/fixed_point_visitor.rs:83:21
  12: mirai::body_visitor::BodyVisitor<E>::visit_body
             at /home/omer/rust/MIRAI/checker/src/body_visitor.rs:193:9
  13: mirai::crate_visitor::CrateVisitor::analyze_body::{{closure}}
             at /home/omer/rust/MIRAI/checker/src/crate_visitor.rs:158:23
  14: mirai::crate_visitor::CrateVisitor::analyze_body
             at /home/omer/rust/MIRAI/checker/src/crate_visitor.rs:145:5
  15: mirai::crate_visitor::CrateVisitor::analyze_some_bodies::{{closure}}
             at /home/omer/rust/MIRAI/checker/src/crate_visitor.rs:103:13
  16: mirai::crate_visitor::CrateVisitor::analyze_some_bodies
             at /home/omer/rust/MIRAI/checker/src/crate_visitor.rs:64:5
  17: mirai::callbacks::MiraiCallbacks::analyze_with_mirai::{{closure}}
             at /home/omer/rust/MIRAI/checker/src/callbacks.rs:233:9
  18: mirai::callbacks::MiraiCallbacks::analyze_with_mirai
             at /home/omer/rust/MIRAI/checker/src/callbacks.rs:197:5
  19: <mirai::callbacks::MiraiCallbacks as rustc_driver::Callbacks>::after_analysis::{{closure}}::{{closure}}
             at /home/omer/rust/MIRAI/checker/src/callbacks.rs:125:26
  20: rustc_interface::passes::QueryContext::enter::{{closure}}
             at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/compiler/rustc_interface/src/passes.rs:742:42
  21: rustc_middle::ty::context::tls::enter_context::{{closure}}
             at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/compiler/rustc_middle/src/ty/context.rs:1734:50
  22: rustc_middle::ty::context::tls::set_tlv
             at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/compiler/rustc_middle/src/ty/context.rs:1718:9
  23: rustc_middle::ty::context::tls::enter_context
             at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/compiler/rustc_middle/src/ty/context.rs:1734:9
  24: rustc_interface::passes::QueryContext::enter
             at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/compiler/rustc_interface/src/passes.rs:742:9
  25: <mirai::callbacks::MiraiCallbacks as rustc_driver::Callbacks>::after_analysis::{{closure}}
             at /home/omer/rust/MIRAI/checker/src/callbacks.rs:121:9
  26: <mirai::callbacks::MiraiCallbacks as rustc_driver::Callbacks>::after_analysis
             at /home/omer/rust/MIRAI/checker/src/callbacks.rs:101:5
  27: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  28: rustc_span::with_source_map
  29: rustc_interface::interface::create_compiler_and_run
  30: rustc_span::with_session_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.51.0-nightly (44e3daf5e 2020-12-31) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `rand`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
Error: Argument (let ((a!1 (and (<= 0 16)
                (>= 18446744073709551615 16)
                (<= 0 |param_1.as AlgSetIv(2).0.1|)
                (>= 18446744073709551615 |param_1.as AlgSetIv(2).0.1|)
                (or (> 0 (+ 16 |param_1.as AlgSetIv(2).0.1|))
                    (< 18446744073709551615 (+ 16 |param_1.as AlgSetIv(2).0.1|))))))
(let ((a!2 (ite (and (= 2 param_1.discr) (not a!1))
                (rem (+ 16 |param_1.as AlgSetIv(2).0.1|) 4294967296)
                (ite (= 1 param_1.discr)
                     12
                     (rem (* 4 |param_1.as ScmRights(0).0.1|) 4294967296)))))
(let ((a!3 (ite (= param_1.discr 6)
                12
                (ite (or (= 4 param_1.discr) (= 3 param_1.discr)) 4 a!2))))
  (ite (= param_1.discr 7) 20 (ite (= param_1.discr 5) 2 a!3))))) at position 1 does not match declaration (declare-fun bvadd ((_ BitVec 128) (_ BitVec 128)) (_ BitVec 128))
thread 'rustc' panicked at 'assertion failed: `(left != right)`
  left: `0`,
 right: `0`: you should never look at the bits of a ZST', /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/compiler/rustc_middle/src/ty/consts/int.rs:234:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/library/core/src/panicking.rs:92:14
   2: rustc_middle::ty::consts::int::ScalarInt::to_bits
             at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/compiler/rustc_middle/src/ty/consts/int.rs:234:9
   3: mirai::block_visitor::BlockVisitor<E>::get_enum_variant_as_constant
             at /home/omer/rust/MIRAI/checker/src/block_visitor.rs:2274:24
   4: mirai::block_visitor::BlockVisitor<E>::visit_constant
             at /home/omer/rust/MIRAI/checker/src/block_visitor.rs:2168:24
   5: mirai::block_visitor::BlockVisitor<E>::visit_use
             at /home/omer/rust/MIRAI/checker/src/block_visitor.rs:1363:35
   6: mirai::block_visitor::BlockVisitor<E>::visit_rvalue
             at /home/omer/rust/MIRAI/checker/src/block_visitor.rs:1302:17
   7: mirai::block_visitor::BlockVisitor<E>::visit_assign
             at /home/omer/rust/MIRAI/checker/src/block_visitor.rs:140:9
   8: mirai::block_visitor::BlockVisitor<E>::visit_statement
             at /home/omer/rust/MIRAI/checker/src/block_visitor.rs:107:17
   9: mirai::block_visitor::BlockVisitor<E>::visit_basic_block
             at /home/omer/rust/MIRAI/checker/src/block_visitor.rs:80:17
  10: mirai::fixed_point_visitor::FixedPointVisitor<E>::visit_basic_block
             at /home/omer/rust/MIRAI/checker/src/fixed_point_visitor.rs:131:9
  11: mirai::fixed_point_visitor::FixedPointVisitor<E>::visit_blocks
             at /home/omer/rust/MIRAI/checker/src/fixed_point_visitor.rs:83:21
  12: mirai::body_visitor::BodyVisitor<E>::visit_body
             at /home/omer/rust/MIRAI/checker/src/body_visitor.rs:193:9
  13: mirai::call_visitor::CallVisitor<E>::create_and_cache_function_summary
             at /home/omer/rust/MIRAI/checker/src/call_visitor.rs:114:17
  14: mirai::call_visitor::CallVisitor<E>::get_function_summary
             at /home/omer/rust/MIRAI/checker/src/call_visitor.rs:286:35
  15: mirai::block_visitor::BlockVisitor<E>::visit_call
             at /home/omer/rust/MIRAI/checker/src/block_visitor.rs:600:32
  16: mirai::block_visitor::BlockVisitor<E>::visit_terminator
             at /home/omer/rust/MIRAI/checker/src/block_visitor.rs:263:18
  17: mirai::block_visitor::BlockVisitor<E>::visit_basic_block
             at /home/omer/rust/MIRAI/checker/src/block_visitor.rs:94:13
  18: mirai::fixed_point_visitor::FixedPointVisitor<E>::visit_basic_block
             at /home/omer/rust/MIRAI/checker/src/fixed_point_visitor.rs:131:9
  19: mirai::fixed_point_visitor::FixedPointVisitor<E>::visit_blocks
             at /home/omer/rust/MIRAI/checker/src/fixed_point_visitor.rs:83:21
  20: mirai::body_visitor::BodyVisitor<E>::visit_body
             at /home/omer/rust/MIRAI/checker/src/body_visitor.rs:193:9
  21: mirai::crate_visitor::CrateVisitor::analyze_body::{{closure}}
             at /home/omer/rust/MIRAI/checker/src/crate_visitor.rs:158:23
  22: mirai::crate_visitor::CrateVisitor::analyze_body
             at /home/omer/rust/MIRAI/checker/src/crate_visitor.rs:145:5
  23: mirai::crate_visitor::CrateVisitor::analyze_some_bodies::{{closure}}
             at /home/omer/rust/MIRAI/checker/src/crate_visitor.rs:103:13
  24: mirai::crate_visitor::CrateVisitor::analyze_some_bodies
             at /home/omer/rust/MIRAI/checker/src/crate_visitor.rs:64:5
  25: mirai::callbacks::MiraiCallbacks::analyze_with_mirai::{{closure}}
             at /home/omer/rust/MIRAI/checker/src/callbacks.rs:233:9
  26: mirai::callbacks::MiraiCallbacks::analyze_with_mirai
             at /home/omer/rust/MIRAI/checker/src/callbacks.rs:197:5
  27: <mirai::callbacks::MiraiCallbacks as rustc_driver::Callbacks>::after_analysis::{{closure}}::{{closure}}
             at /home/omer/rust/MIRAI/checker/src/callbacks.rs:125:26
  28: rustc_interface::passes::QueryContext::enter::{{closure}}
             at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/compiler/rustc_interface/src/passes.rs:742:42
  29: rustc_middle::ty::context::tls::enter_context::{{closure}}
             at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/compiler/rustc_middle/src/ty/context.rs:1734:50
  30: rustc_middle::ty::context::tls::set_tlv
             at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/compiler/rustc_middle/src/ty/context.rs:1718:9
  31: rustc_middle::ty::context::tls::enter_context
             at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/compiler/rustc_middle/src/ty/context.rs:1734:9
  32: rustc_interface::passes::QueryContext::enter
             at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/compiler/rustc_interface/src/passes.rs:742:9
  33: <mirai::callbacks::MiraiCallbacks as rustc_driver::Callbacks>::after_analysis::{{closure}}
             at /home/omer/rust/MIRAI/checker/src/callbacks.rs:121:9
  34: <mirai::callbacks::MiraiCallbacks as rustc_driver::Callbacks>::after_analysis
             at /home/omer/rust/MIRAI/checker/src/callbacks.rs:101:5
  35: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  36: rustc_span::with_source_map
  37: rustc_interface::interface::create_compiler_and_run
  38: rustc_span::with_session_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.51.0-nightly (44e3daf5e 2020-12-31) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: internal compiler error: Encountered error `Unimplemented` selecting `Binder(<impl futures_core::Future as futures_core::Future>)` during codegen
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/codegen.rs:68:32

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:974:13
stack backtrace:
   0:     0x7fee354037f7 - std::backtrace_rs::backtrace::libunwind::trace::h746c3e9529d524bc
                               at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7fee354037f7 - std::backtrace_rs::backtrace::trace_unsynchronized::h84373278bfb39e0c
                               at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fee354037f7 - std::sys_common::backtrace::_print_fmt::h517324efde750597
                               at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7fee354037f7 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf594ab77fac89284
                               at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7fee3547407c - core::fmt::write::h3868db8542c90941
                               at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/library/core/src/fmt/mod.rs:1078:17
   5:     0x7fee353f5732 - std::io::Write::write_fmt::h3f6656f045fa877f
                               at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/library/std/src/io/mod.rs:1519:15
   6:     0x7fee354074c5 - std::sys_common::backtrace::_print::hda7655c057c24dcc
                               at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7fee354074c5 - std::sys_common::backtrace::print::h546a6c8431d46287
                               at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7fee354074c5 - std::panicking::default_hook::{{closure}}::h006dd083853faf51
                               at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/library/std/src/panicking.rs:208:50
   9:     0x7fee35407023 - std::panicking::default_hook::hf0f9afb1017317fc
                               at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/library/std/src/panicking.rs:225:9
  10:     0x7fee35c6d69b - rustc_driver::report_ice::h1a7ab7fc7b8fd641
  11:     0x7fee35407dc6 - std::panicking::rust_panic_with_hook::hb7a19826c029b1d6
                               at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/library/std/src/panicking.rs:595:17
  12:     0x7fee354078e7 - std::panicking::begin_panic_handler::{{closure}}::hde71edcd925d0c5e
                               at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/library/std/src/panicking.rs:497:13
  13:     0x7fee35403cbc - std::sys_common::backtrace::__rust_end_short_backtrace::h8a3c7d6cea578919
                               at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/library/std/src/sys_common/backtrace.rs:141:18
  14:     0x7fee35407849 - rust_begin_unwind
                               at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/library/std/src/panicking.rs:493:5
  15:     0x7fee354077fb - std::panicking::begin_panic_fmt::hee67ce14b77d0396
                               at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/library/std/src/panicking.rs:435:5
  16:     0x7fee38daede3 - rustc_errors::HandlerInner::flush_delayed::h336555a5d5079cda
  17:     0x7fee38dad664 - <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop::he52694f8b8fafc7c
  18:     0x7fee3815f1e8 - core::ptr::drop_in_place::h74778df8555d5695
  19:     0x7fee3816131d - <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop::h20680b898398c076
  20:     0x7fee3815eddd - core::ptr::drop_in_place::h4912fedfb922e217
  21:     0x7fee3815cde3 - rustc_span::with_source_map::ha7a34f5cae8f35d5
  22:     0x7fee381684ea - rustc_interface::interface::create_compiler_and_run::hadd076a85b89b30e
  23:     0x7fee3815cee5 - rustc_span::with_session_globals::h15fe66818ce82a14
  24:     0x7fee3816328b - std::sys_common::backtrace::__rust_begin_short_backtrace::h64a4b3a8ddd28b5c
  25:     0x7fee38140dea - core::ops::function::FnOnce::call_once{{vtable.shim}}::h151269a6222c3e41
  26:     0x7fee35417fea - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hea1090dbdcecbf5a
                               at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/library/alloc/src/boxed.rs:1328:9
  27:     0x7fee35417fea - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8d5723d3912bd325
                               at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/library/alloc/src/boxed.rs:1328:9
  28:     0x7fee35417fea - std::sys::unix::thread::Thread::new::thread_start::hc17a425ca2995724
                               at /rustc/44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e/library/std/src/sys/unix/thread.rs:71:17
  29:     0x7fee304f56db - start_thread
  30:     0x7fee2fe8071f - __clone
  31:                0x0 - <unknown>

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.51.0-nightly (44e3daf5e 2020-12-31) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
thread panicked while panicking. aborting.
Error: operator is applied to arguments of the wrong sort
error: build failed

Environment

Using the version in MIRAI's rust-toolchain file.

I am actively working on these issues. The rust compiler's tendency to panic for obscure reasons certainly does not help. For the time being I am focusing exclusively on the Diem crates. You can get more traction if you first build your crate with the normal compiler and then build just your crate with MIRAI. (Touch the lib.rs of your crate. Be sure to use the same Rust flags. Remember to set RUSTFLAGS="-Z always_encode_mir in your environment.)