Skip to content

Standard library function "backtrace_rs::backtrace::trace_unsynchronized" does not codegen (closure crash) #220

Description

@danielsn
error: internal compiler error: compiler/rustc_middle/src/ty/fold.rs:829:17: Trying to collect bound vars with a bound region: DebruijnIndex(0) BoundRegion { var: 0, kind: BrAnon(0) }

related #109

Activity

  1. avanhatt commented on Jun 18, 2021

    @avanhatt
    Contributor

    I think this is the same error I see when trying to build std lib after the #233 fix.

  2. avanhatt commented on Jun 21, 2021

    @avanhatt
    Contributor

    Relevant comment:

                ty::ReLateBound(index, _br) if *index == self.binder_index => {
                    // If you hit this, you should be using `Binder::bind_with_vars` or `Binder::rebind`
                    bug!("Trying to collect bound vars with a bound region: {:?} {:?}", index, _br)
                }
  3. avanhatt commented on Jun 21, 2021

    @avanhatt
    Contributor

    I suspect the skip_binder here is what needs to change:

            let instance = Instance::resolve(
                self.tcx,
                ty::ParamEnv::reveal_all(),
                def_id,
                trait_ref_t.skip_binder().substs,
            )
            .unwrap()
            .unwrap();
  4. self-assigned this
    on Jun 21, 2021
  5. avanhatt commented on Jun 21, 2021

    @avanhatt
    Contributor

    A change to skip_binder seems to fix the listed error; but it seems trace_unsynchronized still fails to compile, now with an issue with the FnOnce trait.

  6. avanhatt commented on Jun 28, 2021

    @avanhatt
    Contributor

    Update: on dc073e5 we get further into compilation, but still fail with:

    thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', compiler/rustc_codegen_llvm/src/gotoc/statement.rs:292:41
    Backtrace
    stack backtrace:
       0: rust_begin_unwind
                 at ./src/panicking.rs:515:5
       1: core::panicking::panic_fmt
                 at /home/ubuntu/rmc/library/core/src/panicking.rs:92:14
       2: core::panicking::panic_bounds_check
                 at /home/ubuntu/rmc/library/core/src/panicking.rs:69:5
       3: <usize as core::slice::index::SliceIndex<[T]>>::index
                 at /home/ubuntu/rmc/library/core/src/slice/index.rs:184:10
       4: core::slice::index::<impl core::ops::index::Index<I> for [T]>::index
                 at /home/ubuntu/rmc/library/core/src/slice/index.rs:15:9
       5: <alloc::vec::Vec<T,A> as core::ops::index::Index<I>>::index
                 at /home/ubuntu/rmc/library/alloc/src/vec/mod.rs:2445:9
       6: rustc_codegen_llvm::gotoc::statement::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_funcall
                 at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/statement.rs:292:41
       7: rustc_codegen_llvm::gotoc::statement::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_terminator
                 at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/statement.rs:62:17
       8: rustc_codegen_llvm::gotoc::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_block
                 at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/mod.rs:63:28
       9: rustc_codegen_llvm::gotoc::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_function::{{closure}}
                 at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/mod.rs:145:71
      10: core::iter::traits::iterator::Iterator::for_each::call::{{closure}}
                 at /home/ubuntu/rmc/library/core/src/iter/traits/iterator.rs:733:29
      11: core::iter::adapters::map::map_fold::{{closure}}
                 at /home/ubuntu/rmc/library/core/src/iter/adapters/map.rs:82:21
      12: <core::iter::adapters::enumerate::Enumerate<I> as core::iter::traits::iterator::Iterator>::fold::enumerate::{{closure}}
                 at /home/ubuntu/rmc/library/core/src/iter/adapters/enumerate.rs:104:27
      13: core::iter::traits::iterator::Iterator::fold
                 at /home/ubuntu/rmc/library/core/src/iter/traits/iterator.rs:2153:21
      14: <core::iter::adapters::enumerate::Enumerate<I> as core::iter::traits::iterator::Iterator>::fold
                 at /home/ubuntu/rmc/library/core/src/iter/adapters/enumerate.rs:110:9
      15: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
                 at /home/ubuntu/rmc/library/core/src/iter/adapters/map.rs:122:9
      16: core::iter::traits::iterator::Iterator::for_each
                 at /home/ubuntu/rmc/library/core/src/iter/traits/iterator.rs:736:9
      17: rustc_codegen_llvm::gotoc::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_function
                 at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/mod.rs:145:13
      18: <rustc_codegen_llvm::gotoc::GotocCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
                 at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/mod.rs:316:47
      19: rustc_interface::passes::start_codegen::{{closure}}
                 at /home/ubuntu/rmc/compiler/rustc_interface/src/passes.rs:1060:9
      20: rustc_data_structures::profiling::VerboseTimingGuard::run
                 at /home/ubuntu/rmc/compiler/rustc_data_structures/src/profiling.rs:573:9
      21: rustc_session::utils::<impl rustc_session::session::Session>::time
                 at /home/ubuntu/rmc/compiler/rustc_session/src/utils.rs:16:9
      22: rustc_interface::passes::start_codegen
                 at /home/ubuntu/rmc/compiler/rustc_interface/src/passes.rs:1059:19
      23: rustc_interface::queries::Queries::ongoing_codegen::{{closure}}::{{closure}}
                 at /home/ubuntu/rmc/compiler/rustc_interface/src/queries.rs:295:20
      24: rustc_interface::passes::QueryContext::enter::{{closure}}
                 at /home/ubuntu/rmc/compiler/rustc_interface/src/passes.rs:799:42
      25: rustc_middle::ty::context::tls::enter_context::{{closure}}
                 at /home/ubuntu/rmc/compiler/rustc_middle/src/ty/context.rs:1744:50
      26: rustc_middle::ty::context::tls::set_tlv
                 at /home/ubuntu/rmc/compiler/rustc_middle/src/ty/context.rs:1728:9
      27: rustc_middle::ty::context::tls::enter_context
                 at /home/ubuntu/rmc/compiler/rustc_middle/src/ty/context.rs:1744:9
      28: rustc_interface::passes::QueryContext::enter
                 at /home/ubuntu/rmc/compiler/rustc_interface/src/passes.rs:799:9
      29: rustc_interface::queries::Queries::ongoing_codegen::{{closure}}
                 at /home/ubuntu/rmc/compiler/rustc_interface/src/queries.rs:286:13
      30: rustc_interface::queries::Query<T>::compute
                 at /home/ubuntu/rmc/compiler/rustc_interface/src/queries.rs:40:28
      31: rustc_interface::queries::Queries::ongoing_codegen
                 at /home/ubuntu/rmc/compiler/rustc_interface/src/queries.rs:284:9
      32: rustc_driver::run_compiler::{{closure}}::{{closure}}
                 at /home/ubuntu/rmc/compiler/rustc_driver/src/lib.rs:414:13
      33: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
                 at /home/ubuntu/rmc/compiler/rustc_interface/src/queries.rs:435:19
      34: rustc_driver::run_compiler::{{closure}}
                 at /home/ubuntu/rmc/compiler/rustc_driver/src/lib.rs:313:22
      35: rustc_interface::interface::create_compiler_and_run::{{closure}}
                 at /home/ubuntu/rmc/compiler/rustc_interface/src/interface.rs:208:13
      36: rustc_span::with_source_map
                 at /home/ubuntu/rmc/compiler/rustc_span/src/lib.rs:873:5
      37: rustc_interface::interface::create_compiler_and_run
                 at /home/ubuntu/rmc/compiler/rustc_interface/src/interface.rs:202:5
      38: rustc_interface::interface::run_compiler::{{closure}}
                 at /home/ubuntu/rmc/compiler/rustc_interface/src/interface.rs:224:12
      39: rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}}::{{closure}}
                 at /home/ubuntu/rmc/compiler/rustc_interface/src/util.rs:158:13
      40: scoped_tls::ScopedKey<T>::set
                 at /home/ubuntu/.cargo/registry/src/github.life-white.uk-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137:9
      41: rustc_span::with_session_globals
                 at /home/ubuntu/rmc/compiler/rustc_span/src/lib.rs:104:5
      42: rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}}
                 at /home/ubuntu/rmc/compiler/rustc_interface/src/util.rs:156:9
      43: rustc_interface::util::scoped_thread::{{closure}}
                 at /home/ubuntu/rmc/compiler/rustc_interface/src/util.rs:131:24
    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.55.0-dev running on x86_64-unknown-linux-gnu
    
    note: compiler flags: -Z force-unstable-if-unmarked -Z trim-diagnostic-paths=no -Z codegen-backend=gotoc -C embed-bitcode=no -C debuginfo=2 --crate-type rlib
    
    note: some of the compiler flags provided by cargo are hidden
    
    query stack during panic:
    end of query stack
    
  7. changed the title [-]Standard library function `"backtrace_rs::backtrace::trace_unsynchronized"` does not codegen[/-] [+]Standard library function `"backtrace_rs::backtrace::trace_unsynchronized"` does not codegen (closure crash)[/+] on Jun 29, 2021
  8. avanhatt commented on Jun 29, 2021

    @avanhatt
    Contributor

    Minimal case for the same crash; we fail on boxed closure impls.

    fn main() {
        // Create a boxed once-callable closure
        let f: Box<dyn FnOnce()> = Box::new(|| {
        });
        // Call it
        f();
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions