-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Nightly with MIRI and FFI #86261
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
Comments
Regressed between nightly-2021-06-08 and nightly-2021-06-09, which is e4a6032...ed597e7, which corresponds to rust-lang/miri@5dde0fe...c8713c2 (which includes rust-lang/miri#1776 that touches |
@hyd-dev found out that the issue boils down to this strange bit of code #[no_mangle]
#[cfg(feature="std")]
use std::{thread,panic, io, boxed, any, string}; Does it make any sense to put |
@RalfJung It doesn't -- it even generates a warning:
|
@rustbot claim |
Filter out items other than non-generic functions and statics in our version of `exported_symbols` [`#[no_mangle]` on a `use` item](https://docs.rs/brotli-decompressor/2.3.1/src/brotli_decompressor/ffi/mod.rs.html#3-5) can make Miri ICE when compiling a dependency (rust-lang/rust#86261): ```rs #[no_mangle] use std::{thread,panic, io, boxed, any, string}; ``` <details> ``` error: internal compiler error: compiler/rustc_middle/src/ty/mod.rs:1650:13: item_name: no name for DefPath { data: [DisambiguatedDefPathData { data: Misc, disambiguator: 14 }], krate: crate0 } thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1007:9 stack backtrace: 0: std::panicking::begin_panic 1: std::panic::panic_any 2: rustc_errors::HandlerInner::bug 3: rustc_errors::Handler::bug 4: rustc_middle::ty::context::tls::with_opt 5: rustc_middle::util::bug::opt_span_bug_fmt 6: rustc_middle::util::bug::bug_fmt 7: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::item_name 8: rustc_symbol_mangling::symbol_name_provider 9: rustc_query_impl::<impl rustc_query_system::query::config::QueryAccessors<rustc_query_impl::plumbing::QueryCtxt> for rustc_query_impl::queries::symbol_name>::compute 10: rustc_query_system::query::plumbing::get_query_impl 11: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::symbol_name 12: rustc_middle::middle::exported_symbols::ExportedSymbol::symbol_name_for_local_instance 13: rustc_codegen_ssa::back::symbol_export::symbol_name_for_instance_in_crate 14: rustc_codegen_ssa::back::linker::exported_symbols 15: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold 16: rustc_codegen_ssa::back::linker::LinkerInfo::new 17: rustc_codegen_ssa::back::write::start_async_codegen 18: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate 19: rustc_interface::passes::QueryContext::enter 20: rustc_interface::queries::Queries::ongoing_codegen 21: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter 22: rustc_span::with_source_map 23: rustc_interface::interface::create_compiler_and_run 24: rustc_span::with_session_globals note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. 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.54.0-nightly (a50d72158 2021-06-08) running on x86_64-unknown-linux-gnu note: compiler flags: -C embed-bitcode=no -C debuginfo=1 --crate-type lib note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [symbol_name] computing the symbol for `{misc#14}` end of query stack ``` </details> This might be because in #1776, we override the `exported_symbols` query, and our version of `exported_symbols` can return a `use` item which don't have a name if the `use` item is tagged with `#[no_mangle]`, and then: - `rustc_codegen_ssa::back::symbol_export::symbol_name_for_instance_in_crate` is called for for every `exported_symbols`: https://github.com/rust-lang/rust/blob/fb3ea63d9b4c3e9bb90d4250b870faaffb9c8fd2/compiler/rustc_codegen_ssa/src/back/linker.rs#L1300-L1304 - it calls `rustc_middle::middle::exported_symbols::ExportedSymbol::symbol_name_for_local_instance`: https://github.com/rust-lang/rust/blob/fb3ea63d9b4c3e9bb90d4250b870faaffb9c8fd2/compiler/rustc_codegen_ssa/src/back/symbol_export.rs#L412 - which calls `rustc_symbol_mangling::symbol_name_provider`: https://github.com/rust-lang/rust/blob/fb3ea63d9b4c3e9bb90d4250b870faaffb9c8fd2/compiler/rustc_middle/src/middle/exported_symbols.rs#L37-L44 - which calls `item_name`: https://github.com/rust-lang/rust/blob/fb3ea63d9b4c3e9bb90d4250b870faaffb9c8fd2/compiler/rustc_symbol_mangling/src/lib.rs#L216, which triggers the ICE It might also be problematic for https://github.com/rust-lang/miri/blob/d39f0c64b8b369188a73a655716ab56683a6537b/src/shims/foreign_items.rs#L165 which also uses `item_name`, but Miri cannot compile the dependency, so that code can't be reached. Therefore, this PR makes `exported_symbols` filter out all items that are not functions or statics, so all items returned will have a name, which avoids the ICE (I have tested it in the https://github.com/jorgecarleitao/arrow2 repository). (This PR also includes a commit that fixes a small (unrelated) bug for `#[no_mangle]` on associated functions -- I found that because I notice `#[no_mangle]` is supported on associated functions and they should not be filtered out in `exported_symbols`.) Fixes (when the submodule is bumped) rust-lang/rust#86261.
While trying to unpin nightly (2021-03-25) to latest nightly, I have hit an internal compiler error.
Complete build log
It emerged between 2021-03-25 and today's build.
All the details are in the build log. In particular,
rustc 1.55.0-nightly (24bdc6d73 2021-06-12) running on x86_64-unknown-linux-gnu
The error seems to emerge when compiling a transitive dependency, so it is not very easy to reproduce with a minimal example.
The text was updated successfully, but these errors were encountered: