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

rustc panic #52408

Closed
d653 opened this issue Jul 15, 2018 · 1 comment
Closed

rustc panic #52408

d653 opened this issue Jul 15, 2018 · 1 comment

Comments

@d653
Copy link

d653 commented Jul 15, 2018

The code that triggers the bug is divided in two crates, if I try to merge the code to a single crate then it compiles without a panic.

Cargo.toml

[package]
name = "bug"
version = "0.3.0"
authors = ["..."]

[dependencies]
tokio-core = "^0.1"
bug2 = { path = "../bug2" }

main.rs

extern crate tokio_core;
extern crate bug2;
use tokio_core::reactor::Core;
fn main() {
    bug2::test("aaa", Core::new().unwrap().handle());
}

Cargo.toml

[package]
name = "bug2"
version = "0.1.0"
authors = ["..."]

[dependencies]
futures = "^0.1"
tokio-core = "^0.1"

lib.rs

extern crate futures;
extern crate tokio_core;

use futures::stream::Stream;
use futures::sync::mpsc;
use tokio_core::reactor::Handle;
use futures::Future;


fn f2(_ : &Handle){
}


fn f1(receiver: mpsc::UnboundedReceiver<()>, handle : Handle) -> impl Future<Item=(),Error=()> {
    receiver.map(move |_|{
        f2(&handle);
    }).for_each(|_|Ok(()))
}


pub fn test<T: AsRef<str>>(_: T, handle: Handle) {
    handle.spawn(f1(mpsc::unbounded().1,handle.clone()));
}

Result:

$ RUST_BACKTRACE=full cargo build 
   Compiling libc v0.2.42
   Compiling nodrop v0.1.12                                                                                           
   Compiling cfg-if v0.1.4                                                                                            
   Compiling scopeguard v0.3.3                                                                                        
   Compiling byteorder v1.2.3                                                                                         
   Compiling lazy_static v1.0.2                                                                                       
   Compiling memoffset v0.2.1                                                                                         
   Compiling futures v0.1.23                                                                                          
   Compiling lazycell v0.6.0                                                                                          
   Compiling slab v0.4.0                                                                                              
   Compiling scoped-tls v0.1.2                                                                                        
   Compiling arrayvec v0.4.7                                                                                          
   Compiling crossbeam-utils v0.3.2                                                                                   
   Compiling log v0.4.3                                                                                               
   Compiling iovec v0.1.2                                                                                             
   Compiling net2 v0.2.33                                                                                             
   Compiling rand v0.4.2                                                                                              
   Compiling num_cpus v1.8.0                                                                                          
   Compiling bytes v0.4.8                                                                                             
   Compiling crossbeam-epoch v0.4.3                                                                                   
   Compiling mio v0.6.15                                                                                              
   Compiling crossbeam-deque v0.3.1                                                                                   
   Compiling tokio-executor v0.1.2                                                                                    
   Compiling tokio-io v0.1.7                                                                                          
   Compiling tokio-threadpool v0.1.5                                                                                  
   Compiling tokio-timer v0.2.4                                                                                       
   Compiling tokio-codec v0.1.0                                                                                       
   Compiling tokio-reactor v0.1.2                                                                                     
   Compiling tokio-fs v0.1.2                                                                                          
   Compiling tokio-tcp v0.1.0                                                                                         
   Compiling tokio-udp v0.1.1                                                                                         
   Compiling tokio v0.1.7                                                                                             
   Compiling tokio-core v0.1.17                                                                                       
   Compiling bug2 v0.1.0 (file:///home/me/sources/antistorm/bug2)                                                     
   Compiling bug v0.3.0 (file:///home/me/sources/antistorm/bug)                                                       
error: internal compiler error: librustc_mir/monomorphize/collector.rs:760: Cannot create local mono-item for DefId(43/0:9 ~ bug2[df2b]::f2[0])

thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:554:9
stack backtrace:
   0:     0x7f06ef7e044e - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::hd6c46a9a697d3bb0
                               at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1:     0x7f06ef7b7d36 - std::sys_common::backtrace::print::hb45c2623ee574a87
                               at libstd/sys_common/backtrace.rs:71
                               at libstd/sys_common/backtrace.rs:59
   2:     0x7f06ef7e947d - std::panicking::default_hook::{{closure}}::h07311e63483c372f
                               at libstd/panicking.rs:211
   3:     0x7f06ef7e91f0 - std::panicking::default_hook::h028233b8c65b3bae
                               at libstd/panicking.rs:227
   4:     0x7f06ebe83395 - rustc::util::common::panic_hook::hf2c45cd370f93067
   5:     0x7f06ef7e9b43 - std::panicking::rust_panic_with_hook::haf5fc7b5dee91fb6
                               at libstd/panicking.rs:479
   6:     0x7f06eac56f3e - std::panicking::begin_panic::h7d35788894d6c658
   7:     0x7f06eac52811 - rustc_errors::Handler::bug::heb8a9758863e3156
   8:     0x7f06ebae270c - rustc::session::opt_span_bug_fmt::{{closure}}::h5382608adf0a2b3b
   9:     0x7f06ebb9bf59 - rustc::ty::context::tls::with_opt::{{closure}}::h977b3c480aed1c06
  10:     0x7f06ebae35df - rustc::ty::context::tls::with_context_opt::hab811a2b405ba06e
  11:     0x7f06ebb9b9f6 - rustc::ty::context::tls::with_opt::h9dbcf2abf5eccedf
  12:     0x7f06eba311b4 - rustc::session::opt_span_bug_fmt::h8a2450256e82837a
  13:     0x7f06eba31126 - rustc::session::bug_fmt::he893b82c41367e01
  14:     0x7f06ec8d99b9 - rustc_mir::monomorphize::collector::should_monomorphize_locally::h61f3fc7939397156
  15:     0x7f06ec8d9634 - rustc_mir::monomorphize::collector::visit_instance_use::ha5b4c96d3a4a65ef
  16:     0x7f06ec8d9602 - rustc_mir::monomorphize::collector::visit_fn_use::h0faca38b45594912
  17:     0x7f06ec8d910c - <rustc_mir::monomorphize::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_terminator_kind::h2c72726e7afc51de
  18:     0x7f06ec8d7ac1 - rustc_mir::monomorphize::collector::collect_items_rec::h0f4189260a5f2b34
  19:     0x7f06ec8d80f9 - rustc_mir::monomorphize::collector::collect_items_rec::h0f4189260a5f2b34
  20:     0x7f06ec8d80f9 - rustc_mir::monomorphize::collector::collect_items_rec::h0f4189260a5f2b34
  21:     0x7f06ec8d80f9 - rustc_mir::monomorphize::collector::collect_items_rec::h0f4189260a5f2b34
  22:     0x7f06ec8d80f9 - rustc_mir::monomorphize::collector::collect_items_rec::h0f4189260a5f2b34
  23:     0x7f06ec8d80f9 - rustc_mir::monomorphize::collector::collect_items_rec::h0f4189260a5f2b34
  24:     0x7f06ec8d80f9 - rustc_mir::monomorphize::collector::collect_items_rec::h0f4189260a5f2b34
  25:     0x7f06ec8d80f9 - rustc_mir::monomorphize::collector::collect_items_rec::h0f4189260a5f2b34
  26:     0x7f06ecb351b0 - rustc_mir::monomorphize::collector::collect_crate_mono_items::{{closure}}::hfe149b0b8cb481eb
  27:     0x7f06ecb0d8c4 - rustc::util::common::time::hf897241d402a4e9e
  28:     0x7f06ec8d5ce0 - rustc_mir::monomorphize::collector::collect_crate_mono_items::h64944a52b0a9edc3
  29:     0x7f06e54f7276 - rustc::util::common::time::h0d7f9f0f8494d94e
  30:     0x7f06e55b0f94 - rustc_codegen_llvm::base::collect_and_partition_mono_items::h7a7c84af63c01538
  31:     0x7f06ebb9dae8 - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::collect_and_partition_mono_items<'tcx>>::compute::h4cdf9fe96888402e
  32:     0x7f06ebb165e4 - rustc::ty::context::tls::with_context::hc07a3cde95f6473f
  33:     0x7f06eb96641e - rustc::dep_graph::graph::DepGraph::with_task_impl::h144e93e8e7db8c82
  34:     0x7f06ebb435db - rustc::ty::context::tls::with_related_context::h3c918fef702c76f1
  35:     0x7f06ebc92377 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job::h9845e745f16d383c
  36:     0x7f06ebd5dbd9 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query::ha0bb465fedd5ab61
  37:     0x7f06e55b9820 - <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate::h050f6f9fdd741ee2
  38:     0x7f06efb92131 - rustc::util::common::time::hf3bdbd3076e65138
  39:     0x7f06efb8627c - rustc_driver::driver::phase_4_codegen::h6d218d66ccc5b3b1
  40:     0x7f06efb42e38 - rustc_driver::driver::compile_input::{{closure}}::h3ae3822eda7126fa
  41:     0x7f06efb3e3c9 - rustc::ty::context::tls::enter_context::h172e3a71948cf3e8
  42:     0x7f06efbcab7a - <std::thread::local::LocalKey<T>>::with::hbc082df5ff4b92fe
  43:     0x7f06efc3cbbd - rustc::ty::context::TyCtxt::create_and_enter::h140543bc115628f6
  44:     0x7f06efb7fd7c - rustc_driver::driver::compile_input::h77799d53c7077f32
  45:     0x7f06efc0a2c0 - rustc_driver::run_compiler_with_pool::hf70f7dd371076d1f
  46:     0x7f06efb45e7c - <scoped_tls::ScopedKey<T>>::set::hea0904c0d7dcea9c
  47:     0x7f06efb45b71 - <scoped_tls::ScopedKey<T>>::set::h2f59f8491f17e599
  48:     0x7f06efba120a - syntax::with_globals::hb4d6561660afb38b
  49:     0x7f06efb445f2 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h51855e0168324012
  50:     0x7f06ef7f69b9 - __rust_maybe_catch_panic
                               at libpanic_unwind/lib.rs:106
  51:     0x7f06efc07754 - rustc_driver::run::hfad78015aa66f902
  52:     0x7f06efc16eea - rustc_driver::main::hc68ca44052c5c3d1
  53:     0x5572bc845b52 - std::rt::lang_start::{{closure}}::h169c2960103a293d
  54:     0x7f06ef7e9582 - std::panicking::try::do_call::h4ae9a4c7ba6e1e81
                               at libstd/rt.rs:59
                               at libstd/panicking.rs:310
  55:     0x7f06ef7f69b9 - __rust_maybe_catch_panic
                               at libpanic_unwind/lib.rs:106
  56:     0x7f06ef7cbca5 - std::rt::lang_start_internal::hea52cc5b4fec6cb8
                               at libstd/panicking.rs:289
                               at libstd/panic.rs:392
                               at libstd/rt.rs:58
  57:     0x5572bc845bb3 - main
  58:     0x7f06ef3c2f29 - __libc_start_main
  59:     0x5572bc845a38 - <unknown>
query stack during panic:
#0 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: aborting due to previous error


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

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.29.0-nightly (254f8796b 2018-07-13) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

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

error: Could not compile `bug`.                                                                                       

To learn more, run the command again with --verbose.
@pietroalbini
Copy link
Member

Duplicate of #50865

@pietroalbini pietroalbini marked this as a duplicate of #50865 Jul 15, 2018
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

No branches or pull requests

2 participants