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 hangs #34858

Closed
danielwaterworth opened this issue Jul 16, 2016 · 14 comments
Closed

rustc hangs #34858

danielwaterworth opened this issue Jul 16, 2016 · 14 comments

Comments

@danielwaterworth
Copy link

This issue may well be a duplicate, but I don't know enough about rust internals to make that judgement.

I'm using rustc 1.10.0 (cfcb716cf 2016-07-03). This is the commit in my project that makes it hang.

Here's the output with time-passes:

$ cargo rustc --lib -- -Ztime-passes -A warnings
   Compiling qbf v0.1.0 (file:///home/dan/fun/qbf-rust)
warning: the option `Z` is unstable and should only be used on the nightly compiler, but it is currently accepted for backwards compatibility; this will soon change, see issue #31847 for more details
time: 0.008; rss: 50MB  parsing
time: 0.002; rss: 50MB  configuration 1
time: 0.000; rss: 50MB  recursion limit
time: 0.000; rss: 50MB  crate injection
time: 0.042; rss: 93MB  macro loading
time: 0.000; rss: 93MB  plugin loading
time: 0.000; rss: 93MB  plugin registration
time: 0.070; rss: 97MB  expansion
time: 0.005; rss: 97MB  configuration 2
time: 0.000; rss: 97MB  gated configuration checking
time: 0.003; rss: 96MB  maybe building test harness
time: 0.002; rss: 97MB  prelude injection
time: 0.000; rss: 97MB  checking that all macro invocations are gone
time: 0.000; rss: 97MB  checking for inline asm in case the target doesn't support it
time: 0.001; rss: 97MB  complete gated feature checking
time: 0.003; rss: 97MB  assigning node ids
time: 0.001; rss: 97MB  collecting defs
time: 0.004; rss: 97MB  external crate/lib resolution
time: 0.002; rss: 97MB  early lint checks
time: 0.007; rss: 97MB  name resolution
time: 0.005; rss: 99MB  lowering ast -> hir
time: 0.000; rss: 99MB  indexing hir
time: 0.000; rss: 99MB  attribute checking
time: 0.000; rss: 98MB  language item collection
time: 0.000; rss: 98MB  lifetime resolution
time: 0.000; rss: 98MB  looking for entry point
time: 0.000; rss: 98MB  looking for plugin registrar
time: 0.002; rss: 100MB region resolution
time: 0.000; rss: 100MB loop checking
time: 0.000; rss: 100MB static item recursion checking
time: 0.000; rss: 100MB load_dep_graph
time: 0.008; rss: 102MB type collecting
time: 0.000; rss: 102MB variance inference
time: 0.031; rss: 104MB coherence checking
time: 0.014; rss: 104MB wf checking
time: 0.004; rss: 104MB item-types checking
time: 0.256; rss: 111MB item-bodies checking
time: 0.000; rss: 111MB drop-impl checking
time: 0.013; rss: 111MB const checking
time: 0.003; rss: 111MB privacy checking
time: 0.000; rss: 111MB stability index
time: 0.001; rss: 111MB intrinsic checking
time: 0.000; rss: 111MB effect checking
time: 0.004; rss: 111MB match checking
time: 0.002; rss: 113MB liveness checking
time: 0.015; rss: 113MB rvalue checking
time: 0.019; rss: 113MB MIR dump
time: 0.013; rss: 113MB MIR passes
time: 0.028; rss: 113MB borrow checking
time: 0.000; rss: 113MB reachability checking
time: 0.001; rss: 113MB death checking
time: 0.001; rss: 113MB stability checking
time: 0.000; rss: 113MB unused lib feature checking
time: 0.009; rss: 113MB lint checking
time: 0.000; rss: 113MB resolving dependency formats
time: 0.003; rss: 113MB Prepare MIR codegen passes
^C
@danielwaterworth
Copy link
Author

I started looking into this, but gave up. Slow compile times and a segfault when I was building rustc effectively lost you a contributor.

@sanxiyn
Copy link
Member

sanxiyn commented Jul 17, 2016

I believe this is the same case as #33502.

@danielwaterworth
Copy link
Author

Yep, same thing, same stack trace.

@arielb1
Copy link
Contributor

arielb1 commented Jul 17, 2016

segfault while building rustc?

@danielwaterworth
Copy link
Author

yes

@danielwaterworth
Copy link
Author

Is there a work around that works with FnOnce closures?

@danielwaterworth
Copy link
Author

danielwaterworth commented Jul 17, 2016

Here's a much smaller test case:

fn foo<F, X>(cb: F) -> X
    where F : for<'a> FnOnce(&'a u64) -> X {
    foo(move |expr1| {
        cb(expr1)
    })
}

fn main() {
    foo(move |_| ());
}

@arielb1
Copy link
Contributor

arielb1 commented Jul 17, 2016

details?

@danielwaterworth
Copy link
Author

@arielb1, I didn't think it would be reproducible, but it was. I have a core dump. Here's a backtrace:

#0  llvm::DenseMapBase<llvm::DenseMap<llvm::MDNode*, std::vector<llvm::TypedTrackingMDRef<llvm::MDNode>, std::allocator<llvm::TypedTrackingMDRef<llvm::MDNode> > >, llvm::DenseMapInfo<llvm::MDNode*>, llvm::detail::DenseMapPair<llvm::MDNode*, std::vector<llvm::TypedTrackingMDRef<llvm::MDNode>, std::allocator<llvm::TypedTrackingMDRef<llvm::MDNode> > > > >, llvm::MDNode*, std::vector<llvm::TypedTrackingMDRef<llvm::MDNode>, std::allocator<llvm::TypedTrackingMDRef<llvm::MDNode> > >, llvm::DenseMapInfo<llvm::MDNode*>, llvm::detail::DenseMapPair<llvm::MDNode*, std::vector<llvm::TypedTrackingMDRef<llvm::MDNode>, std::allocator<llvm::TypedTrackingMDRef<llvm::MDNode> > > > >::destroyAll (this=0x7f9b82be4080)
    at //home//dan//installed//rust//src//llvm//include/llvm/ADT/DenseMap.h:270
#1  llvm::DenseMap<llvm::MDNode*, std::vector<llvm::TypedTrackingMDRef<llvm::MDNode>, std::allocator<llvm::TypedTrackingMDRef<llvm::MDNode> > >, llvm::DenseMapInfo<llvm::MDNode*>, llvm::detail::DenseMapPair<llvm::MDNode*, std::vector<llvm::TypedTrackingMDRef<llvm::MDNode>, std::allocator<llvm::TypedTrackingMDRef<llvm::MDNode> > > > >::~DenseMap (this=0x7f9b82be4080, __in_chrg=<optimised out>) at //home//dan//installed//rust//src//llvm//include/llvm/ADT/DenseMap.h:574
#2  llvm::DIBuilder::~DIBuilder (this=0x7f9b82be3f00, __in_chrg=<optimised out>) at //home//dan//installed//rust//src//llvm//include/llvm/IR/DIBuilder.h:35
#3  LLVMDIBuilderDispose (Builder=0x7f9b82be3f00) at /home/dan/installed/rust/src/rustllvm/RustWrapper.cpp:288
#4  0x00007f9b8e002689 in rustc_trans::debuginfo::finalize (cx=0x7f9b835f1238) at /home/dan/installed/rust/src/librustc_trans/debuginfo/mod.rs:183
#5  0x00007f9b8df6e592 in rustc_trans::base::trans_crate (tcx=..., mir_map=0x7f9b835f22e8, analysis=...) at /home/dan/installed/rust/src/librustc_trans/base.rs:2554
#6  0x00007f9b8fed67bf in rustc_driver::driver::phase_4_translate_to_llvm::{{closure}} () at /home/dan/installed/rust/src/librustc_driver/driver.rs:1011
#7  0x00007f9b8fc93c6e in {{inlined-root}}::time<rustc_trans::CrateTranslation,closure> (do_it=false, what=..., f=...) at /home/dan/installed/rust/src/librustc/util/common.rs:38
#8  0x00007f9b8fea6b0c in rustc_driver::driver::phase_4_translate_to_llvm (tcx=..., mir_map=..., analysis=...) at /home/dan/installed/rust/src/librustc_driver/driver.rs:1009
#9  0x00007f9b8ff079ff in rustc_driver::driver::compile_input::{{closure}} (tcx=..., mir_map=..., analysis=..., result=...) at /home/dan/installed/rust/src/librustc_driver/driver.rs:203
#10 0x00007f9b8fed00e6 in rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}<closure,core::result::Result<(rustc::session::config::OutputFilenames, rustc_trans::CrateTranslation), usize>> (tcx=...)
    at /home/dan/installed/rust/src/librustc_driver/driver.rs:972
#11 0x00007f9b8fecaf2b in rustc::ty::context::tls::enter::_$u7b$$u7b$closure$u7d$$u7d$::h9d08b024ac32fd21 () at /home/dan/installed/rust/src/librustc_driver/pretty.rs:285
#12 0x00007f9b8fbf4600 in {{inlined-root}}::with<core::cell::Cell<core::option::Option<(*const rustc::ty::context::tls::ThreadLocalGlobalCtxt, *const rustc::ty::context::tls::ThreadLocalInterners)>>,closure,core::result::Result<core::result::Result<(rustc::session::config::OutputFilenames, rustc_trans::CrateTranslation), usize>, usize>> (self=0x7f9b8a739510 <rustc::ty::context::tls::TLS_TCX::h4b589da3ad4497aa>, f=...)
    at /home/dan/installed/rust/src/libstd/thread/local.rs:245
#13 0x00007f9b8fc557b1 in {{inlined-root}}::enter<closure,core::result::Result<core::result::Result<(rustc::session::config::OutputFilenames, rustc_trans::CrateTranslation), usize>, usize>> (gcx=0x7f9b835f5628, 
    interners=0x7f9b835f5628, f=...) at /home/dan/installed/rust/src/librustc/ty/context.rs:902
#14 0x00007f9b8fecce69 in rustc::ty::context::tls::enter_global::_$u7b$$u7b$closure$u7d$$u7d$::h8575bf8dd37062fa () at /home/dan/installed/rust/src/librustc_driver/pretty.rs:285
#15 0x00007f9b8fbf8b26 in {{inlined-root}}::with<core::cell::Cell<fn(syntax_pos::Span, &mut core::fmt::Formatter) -> core::result::Result<(), core::fmt::Error>>,closure,core::result::Result<core::result::Result<(rustc::session::config::OutputFilenames, rustc_trans::CrateTranslation), usize>, usize>> (self=0x7f9b85b8dc00 <syntax_pos::SPAN_DEBUG::h5629cb242cbcd20f>, f=...) at /home/dan/installed/rust/src/libstd/thread/local.rs:245
#16 0x00007f9b8fc5515c in {{inlined-root}}::enter_global<closure,core::result::Result<core::result::Result<(rustc::session::config::OutputFilenames, rustc_trans::CrateTranslation), usize>, usize>> (gcx=..., f=...)
    at /home/dan/installed/rust/src/librustc/ty/context.rs:886
#17 0x00007f9b8fc5bb2e in {{inlined-root}}::create_and_enter<closure,core::result::Result<core::result::Result<(rustc::session::config::OutputFilenames, rustc_trans::CrateTranslation), usize>, usize>> (s=0x7f9b835fb040, 
    arenas=0x7f9b835f9800, def_map=..., named_region_map=..., map=..., freevars=..., maybe_unused_trait_imports=..., region_maps=..., lang_items=..., stability=..., crate_name=..., f=...)
    at /home/dan/installed/rust/src/librustc/ty/context.rs:685
#18 0x00007f9b8fea67e5 in rustc_driver::driver::phase_3_run_analysis_passes<closure,core::result::Result<(rustc::session::config::OutputFilenames, rustc_trans::CrateTranslation), usize>> (sess=0x7f9b835fb040, hir_map=..., analysis=..., 
    resolutions=..., arenas=0x7f9b835f9800, name=..., f=...) at /home/dan/installed/rust/src/librustc_driver/driver.rs:854
#19 0x00007f9b8fe9e5f0 in rustc_driver::driver::compile_input (sess=0x7f9b835fb040, cstore=0x7f9b82a1e210, cfg=..., input=0x7f9b835fbfa0, outdir=0x7f9b835fc190, output=0x7f9b835fc170, addl_plugins=..., control=0x7f9b835faae0)
    at /home/dan/installed/rust/src/librustc_driver/driver.rs:169
#20 0x00007f9b8feb3ba7 in rustc_driver::run_compiler_with_file_loader<syntax::codemap::RealFileLoader> (args=..., callbacks=..., loader=0x1d1d1d1d1d1d1d1d) at /home/dan/installed/rust/src/librustc_driver/lib.rs:220
#21 0x00007f9b8feb2b19 in rustc_driver::run_compiler (args=..., callbacks=...) at /home/dan/installed/rust/src/librustc_driver/lib.rs:157
#22 0x00007f9b8ff0c056 in rustc_driver::run::{{closure}} () at /home/dan/installed/rust/src/librustc_driver/lib.rs:135
#23 0x00007f9b8ff06e22 in rustc_driver::monitor::{{closure}}<closure> () at /home/dan/installed/rust/src/librustc_driver/lib.rs:1043
#24 0x00007f9b8fe7380a in {{inlined-root}}::call_once<(),closure> (self=..., _args=0) at /home/dan/installed/rust/src/libstd/panic.rs:256
#25 0x00007f9b8fec7234 in std::panicking::try::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h4767e083ebe96610 () at /home/dan/installed/rust/src/librustc_driver/pretty.rs:285
#26 0x00007f9b8fbd44b5 in {{inlined-root}}::call<closure> (f=0x7f9b835fe778) at /home/dan/installed/rust/src/libstd/panicking.rs:272
#27 0x00007f9b8f54a458 in __rust_try () from /home/dan/installed/rust/x86_64-unknown-linux-gnu/stage1/lib/libstd-f53fb285.so
#28 0x00007f9b8f54a3b5 in panic_unwind::__rust_maybe_catch_panic (f=0x7f9b8fbd44a0 <{{inlined-root}}::call<closure>>, data=0x7f9b835fe778 "\260\350_\203\233\177", data_ptr=0x7f9b835fe760, vtable_ptr=0x7f9b835fe758)
    at /home/dan/installed/rust/src/libpanic_unwind/lib.rs:91
#29 0x00007f9b8fec719e in std::panicking::try::_$u7b$$u7b$closure$u7d$$u7d$::h5edd11d34a445b2b () at /home/dan/installed/rust/src/librustc_driver/pretty.rs:285
#30 0x00007f9b8fbf76b0 in {{inlined-root}}::with<core::cell::Cell<usize>,closure,core::result::Result<(), Box<Any>>> (self=0x7f9b8f9029e0 <std::panicking::PANIC_COUNT::h99b79c8949805cd2>, f=...)
    at /home/dan/installed/rust/src/libstd/thread/local.rs:245
#31 0x00007f9b8fbd43d8 in {{inlined-root}}::try<(),std::panic::AssertUnwindSafe<closure>> (f=...) at /home/dan/installed/rust/src/libstd/panicking.rs:235
#32 0x00007f9b8fbd3a21 in {{inlined-root}}::catch_unwind<std::panic::AssertUnwindSafe<closure>,()> (f=...) at /home/dan/installed/rust/src/libstd/panic.rs:312
#33 0x00007f9b8fec6fa6 in std::thread::Builder::spawn::_$u7b$$u7b$closure$u7d$$u7d$::hf8ba3712412ac8f6 () at /home/dan/installed/rust/src/librustc_driver/pretty.rs:285
#34 0x00007f9b8fc3a15d in {{inlined-root}}::call_box<(),closure> (self=0x7f9b83677f20, args=0) at /home/dan/installed/rust/src/liballoc/boxed.rs:587
#35 0x00007f9b8f46541c in {{inlined-root}}::call_once<(),()> (self=..., args=0) at /home/dan/installed/rust/src/liballoc/boxed.rs:597
#36 0x00007f9b8f4ee76f in std::sys_common::thread::start_thread (main=0x7f9b836a4050) at /home/dan/installed/rust/src/libstd/sys/common/thread.rs:23
#37 0x00007f9b8f5185d5 in std::sys::thread::{{impl}}::new::thread_start (main=0x7f9b836a4050) at /home/dan/installed/rust/src/libstd/sys/unix/thread.rs:73
#38 0x00007f9b852336aa in start_thread (arg=0x7f9b835ff700) at pthread_create.c:333
#39 0x00007f9b8f0a513d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

@arielb1
Copy link
Contributor

arielb1 commented Jul 17, 2016

cc @alexcrichton

@alexcrichton
Copy link
Member

This may get fixed by #34743 where we're upgrading LLVM, but that's purely a guess. Maybe worth trying after it's merged though?

It may also be possible to not compile with debuginfo as that may be the culprit here

@serpilliere
Copy link

Hi!
On rustc 1.7.0, the compilation of the minimalist example outputs:

src/main.rs:1:1: 6:2 warning: function cannot return without recurring, #[warn(unconditional_recursion)] on by default
src/main.rs:1 fn foo<F, X>(cb: F) -> X
src/main.rs:2     where F : for<'a> FnOnce(&'a u64) -> X {
src/main.rs:3     foo(move |expr1| {
src/main.rs:4         cb(expr1)
src/main.rs:5     })
src/main.rs:6 }
src/main.rs:3:5: 5:7 note: recursive call site
src/main.rs:3     foo(move |expr1| {
src/main.rs:4         cb(expr1)
src/main.rs:5     })
src/main.rs:1:1: 6:2 help: a `loop` may express intention better if this is on purpose
src/main.rs:1:1: 6:2 error: reached the recursion limit during monomorphization
src/main.rs:1 fn foo<F, X>(cb: F) -> X
src/main.rs:2     where F : for<'a> FnOnce(&'a u64) -> X {
src/main.rs:3     foo(move |expr1| {
src/main.rs:4         cb(expr1)
src/main.rs:5     })
src/main.rs:6 }

On rustc 1.13.0, no errors are raised, and the compilation hangs forever.
Here are some debug traces during compilation:

$ cargo rustc  -- -Ztime-passes -A warnings
   Compiling test_bug v0.1.0 (file://test_bug)
warning: the option `Z` is unstable and should only be used on the nightly compiler, but it is currently accepted for backwards compatibility; this will soon change, see issue #31847 for more details

time: 0.000; rss: 45MB  parsing
time: 0.000; rss: 45MB  recursion limit
time: 0.000; rss: 45MB  crate injection
time: 0.000; rss: 45MB  plugin loading
time: 0.000; rss: 45MB  plugin registration
time: 0.019; rss: 65MB  expansion
time: 0.000; rss: 65MB  maybe building test harness
time: 0.000; rss: 65MB  maybe creating a macro crate
time: 0.000; rss: 65MB  checking for inline asm in case the target doesn't support it
time: 0.000; rss: 65MB  complete gated feature checking
time: 0.000; rss: 65MB  collecting defs
time: 0.000; rss: 65MB  early lint checks
time: 0.000; rss: 65MB  AST validation
time: 0.003; rss: 65MB  name resolution
time: 0.000; rss: 65MB  lowering ast -> hir
time: 0.000; rss: 65MB  indexing hir
time: 0.000; rss: 65MB  attribute checking
time: 0.000; rss: 65MB  language item collection
time: 0.000; rss: 65MB  lifetime resolution
time: 0.000; rss: 65MB  looking for entry point
time: 0.000; rss: 65MB  looking for plugin registrar
time: 0.000; rss: 65MB  region resolution
time: 0.000; rss: 65MB  loop checking
time: 0.000; rss: 65MB  static item recursion checking
time: 0.000; rss: 69MB  compute_incremental_hashes_map
time: 0.000; rss: 69MB  load_dep_graph
time: 0.000; rss: 69MB  type collecting
time: 0.000; rss: 69MB  variance inference
time: 0.010; rss: 69MB  coherence checking
time: 0.000; rss: 69MB  wf checking
time: 0.000; rss: 69MB  item-types checking
time: 0.001; rss: 69MB  item-bodies checking
time: 0.000; rss: 69MB  drop-impl checking
time: 0.000; rss: 69MB  const checking
time: 0.000; rss: 69MB  privacy checking
time: 0.000; rss: 69MB  stability index
time: 0.000; rss: 69MB  intrinsic checking
time: 0.000; rss: 69MB  effect checking
time: 0.000; rss: 69MB  match checking
time: 0.000; rss: 69MB  liveness checking
time: 0.000; rss: 69MB  rvalue checking
time: 0.000; rss: 69MB  MIR dump
  time: 0.000; rss: 69MB        SimplifyCfg
  time: 0.000; rss: 69MB        QualifyAndPromoteConstants
  time: 0.000; rss: 69MB        TypeckMir
  time: 0.000; rss: 69MB        SimplifyBranches
  time: 0.000; rss: 69MB        SimplifyCfg
time: 0.000; rss: 69MB  MIR passes
time: 0.000; rss: 69MB  borrow checking
time: 0.000; rss: 69MB  reachability checking
time: 0.000; rss: 69MB  death checking
time: 0.000; rss: 69MB  stability checking
time: 0.000; rss: 69MB  unused lib feature checking
time: 0.000; rss: 69MB  lint checking
time: 0.001; rss: 69MB  resolving dependency formats
  time: 0.000; rss: 69MB        NoLandingPads
  time: 0.000; rss: 69MB        SimplifyCfg
  time: 0.000; rss: 69MB        EraseRegions
  time: 0.000; rss: 69MB        AddCallGuards
  time: 0.000; rss: 69MB        ElaborateDrops
  time: 0.000; rss: 69MB        NoLandingPads
  time: 0.000; rss: 69MB        SimplifyCfg
  time: 0.000; rss: 69MB        InstCombine
  time: 0.000; rss: 69MB        Deaggregator
  time: 0.000; rss: 69MB        CopyPropagation
  time: 0.000; rss: 69MB        AddCallGuards
  time: 0.000; rss: 69MB        PreTrans
time: 0.000; rss: 69MB  Prepare MIR codegen passes
  time: 0.000; rss: 69MB        write metadata

Is it still a known bug, or is there any fix for it?

@cyplo
Copy link
Contributor

cyplo commented Apr 23, 2017

It does not hang on 1.16 it seems - is the error given what would you expect, @danielwaterworth ?

✘ ⚙ cyryl@skinnyv  test3  rustc --version
rustc 1.16.0 (30cf806 2017-03-10)
⚙ cyryl@skinnyv  test3  rustc test.rs
warning: function cannot return without recurring, #[warn(unconditional_recursion)] on by default
--> test.rs:1:1
|
1 | fn foo<F, X>(cb: F) -> X
| ^ starting here...
2 | | where F : for<'a> FnOnce(&'a u64) -> X {
3 | | foo(move |expr1| {
4 | | cb(expr1)
5 | | })
6 | | }
| |
^ ...ending here
|
note: recursive call site
--> test.rs:3:5
|
3 | foo(move |expr1| {
| ^ starting here...
4 | | cb(expr1)
5 | | })
| |
_^ ...ending here
= help: a loop may express intention better if this is on purpose

error: reached the type-length limit while instantiating foo::<[closure@test.rs:3:9: 5:6 cb:[closure@test.rs:3:9: 5:6 cb:...
--> test.rs:1:1
|
1 | fn foo<F, X>(cb: F) -> X
| ^ starting here...
2 | | where F : for<'a> FnOnce(&'a u64) -> X {
3 | | foo(move |expr1| {
4 | | cb(expr1)
5 | | })
6 | | }
| |
^ ...ending here
|
= note: consider adding a #![type_length_limit="2097152"] attribute to your crate

error: aborting due to previous error

@danielwaterworth
Copy link
Author

Yes, much better.

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

6 participants