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

internal compiler error in closure #1312

Open
arnaudgolfouse opened this issue Jan 2, 2025 · 0 comments
Open

internal compiler error in closure #1312

arnaudgolfouse opened this issue Jan 2, 2025 · 0 comments

Comments

@arnaudgolfouse
Copy link
Collaborator

The following code crashes Creusot:

pub fn foo() {
    let my_closure = |x: Option<i32>| match x {
        Some(y) => y,
        None => unreachable!("unwrapped None"),
    };
}

with:

error: internal compiler error: compiler/rustc_middle/src/ty/mod.rs:1607:13: item_name: no name for DefPath { data: [DisambiguatedDefPathData { data: ValueNs("foo"), disambiguator: 0 }, DisambiguatedDefPathData { data: Closure, disambiguator: 0 }], krate: crate0 }

Here is the full backtrace:

Backtrace
thread 'rustc' panicked at compiler/rustc_middle/src/ty/mod.rs:1607:13:

Box<dyn Any>
stack backtrace:
   0:     0x7f1d3b7744c5 - std::backtrace_rs::backtrace::libunwind::trace::h628b2ecbdacacbe5
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x7f1d3b7744c5 - std::backtrace_rs::backtrace::trace_unsynchronized::h933c064eeefc640a
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f1d3b7744c5 - std::backtrace::Backtrace::create::hbf8273595133b7ce
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/library/std/src/backtrace.rs:331:13
   3:     0x7f1d3b774415 - std::backtrace::Backtrace::force_capture::ha15f2f878e76c99b
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/library/std/src/backtrace.rs:312:9
   4:     0x7f1d3ec3ffaf - std[ceb29ca52b686cc8]::panicking::update_hook::<alloc[e8b8252ce035784e]::boxed::Box<rustc_driver_impl[3b5aaec34fa30fe1]::install_ice_hook::{closure#0}>>::{closure#0}
   5:     0x7f1d3b78f1cf - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h8b761a2279615420
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/library/alloc/src/boxed.rs:2163:9
   6:     0x7f1d3b78f1cf - std::panicking::rust_panic_with_hook::hc6c98b37b413d838
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/library/std/src/panicking.rs:808:13
   7:     0x7f1d3ec79d51 - std[ceb29ca52b686cc8]::panicking::begin_panic::<rustc_errors[fdf9495d21ebd0e3]::ExplicitBug>::{closure#0}
   8:     0x7f1d3ec6cd06 - std[ceb29ca52b686cc8]::sys::backtrace::__rust_end_short_backtrace::<std[ceb29ca52b686cc8]::panicking::begin_panic<rustc_errors[fdf9495d21ebd0e3]::ExplicitBug>::{closure#0}, !>
   9:     0x7f1d3ec6ccb6 - std[ceb29ca52b686cc8]::panicking::begin_panic::<rustc_errors[fdf9495d21ebd0e3]::ExplicitBug>
  10:     0x7f1d3ec83391 - <rustc_errors[fdf9495d21ebd0e3]::diagnostic::BugAbort as rustc_errors[fdf9495d21ebd0e3]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7f1d3f22da14 - rustc_middle[324294c51e6e2842]::util::bug::opt_span_bug_fmt::<rustc_span[f405e44d3411febf]::span_encoding::Span>::{closure#0}
  12:     0x7f1d3f213bba - rustc_middle[324294c51e6e2842]::ty::context::tls::with_opt::<rustc_middle[324294c51e6e2842]::util::bug::opt_span_bug_fmt<rustc_span[f405e44d3411febf]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7f1d3f213a3b - rustc_middle[324294c51e6e2842]::ty::context::tls::with_context_opt::<rustc_middle[324294c51e6e2842]::ty::context::tls::with_opt<rustc_middle[324294c51e6e2842]::util::bug::opt_span_bug_fmt<rustc_span[f405e44d3411febf]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7f1d3d00cf30 - rustc_middle[324294c51e6e2842]::util::bug::bug_fmt
  15:     0x7f1d4093bd14 - <rustc_middle[324294c51e6e2842]::ty::context::TyCtxt>::item_name
  16:     0x55e857820c4a - creusot::backend::dependency::Dependency::base_ident::haaff2866aa67713e
                               at creusot/creusot/src/backend/dependency.rs:97:44
  17:     0x55e85791b27e - creusot::backend::clone_map::CloneNames::insert::{{closure}}::h7346ac959cc8c60d
                               at creusot/creusot/src/backend/clone_map.rs:301:13
  18:     0x55e857824493 - indexmap::map::core::entry::Entry<K,V>::or_insert_with::hc5620de915533565
                               at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/indexmap-2.7.0/src/map/core/entry.rs:76:50
  19:     0x55e857645fc7 - creusot::backend::clone_map::CloneNames::insert::hff6e4717dcf668f8
                               at creusot/creusot/src/backend/clone_map.rs:289:9
  20:     0x55e857c75c50 - <creusot::backend::clone_map::elaborator::ExpansionProxy as creusot::backend::clone_map::Namer>::insert::hfa73b3b1d07be4a5
                               at creusot/creusot/src/backend/clone_map/elaborator.rs:80:9
  21:     0x55e85764a290 - creusot::backend::clone_map::Namer::promoted::hb8a6a9397499b8ec
                               at creusot/creusot/src/backend/clone_map.rs:142:9
  22:     0x55e85786b00a - creusot::backend::program::<impl creusot::translation::fmir::Operand>::to_why::hc1517a63f625eb7c
                               at creusot/creusot/src/backend/program.rs:290:45
  23:     0x55e85786ff42 - creusot::backend::program::<impl creusot::translation::fmir::RValue>::to_why::hbecc970c6db6cc19
                               at creusot/creusot/src/backend/program.rs:308:36
  24:     0x55e85787c54e - creusot::backend::program::<impl creusot::translation::fmir::Statement>::to_why::h1a6474f4987a230d
                               at creusot/creusot/src/backend/program.rs:917:27
  25:     0x55e857879d8d - creusot::backend::program::<impl creusot::translation::fmir::Block>::to_why::h7bed19fe472fcbbe
                               at creusot/creusot/src/backend/program.rs:691:24
  26:     0x55e857bc64cf - creusot::backend::program::component_to_defn::h435f5c067bb10291
                               at creusot/creusot/src/backend/program.rs:228:20
  27:     0x55e857bc50be - creusot::backend::program::to_why::{{closure}}::h621307ee8c2641bb
                               at creusot/creusot/src/backend/program.rs:139:18
  28:     0x55e857bb14a2 - core::iter::adapters::map::map_fold::{{closure}}::h077311c5a1433ce7
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/library/core/src/iter/adapters/map.rs:89:28
  29:     0x55e857ae4084 - <alloc::vec::into_iter::IntoIter<T,A> as core::iter::traits::iterator::Iterator>::fold::ha9131884bdf0457d
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/library/alloc/src/vec/into_iter.rs:317:25
  30:     0x55e857b99740 - <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold::hee446e235b0e6cef
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/library/core/src/iter/adapters/map.rs:129:9
  31:     0x55e857bab246 - core::iter::traits::iterator::Iterator::for_each::hd90846fb14559cf1
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/library/core/src/iter/traits/iterator.rs:818:9
  32:     0x55e857705dd4 - alloc::vec::Vec<T,A>::extend_trusted::h6b6e791b50499067
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/library/alloc/src/vec/mod.rs:3113:17
  33:     0x55e85774075b - <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<T,I>>::spec_extend::he881e812c70fa4cf
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/library/alloc/src/vec/spec_extend.rs:26:9
  34:     0x55e8576e9050 - <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter::h7a52bcc7d3752dbf
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/library/alloc/src/vec/spec_from_iter_nested.rs:62:9
  35:     0x55e85772b62e - alloc::vec::in_place_collect::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec<T>>::from_iter::h9c1d6a3c701bb2c1
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/library/alloc/src/vec/in_place_collect.rs:246:9
  36:     0x55e85773eeb9 - <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter::hc50fbd712cda699e
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/library/alloc/src/vec/mod.rs:2977:9
  37:     0x55e857ba9c7e - core::iter::traits::iterator::Iterator::collect::hdb1893665d4e65b5
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/library/core/src/iter/traits/iterator.rs:2005:9
  38:     0x55e857bc31c1 - creusot::backend::program::to_why::h2ff42f6089bdb63c
                               at creusot/creusot/src/backend/program.rs:137:29
  39:     0x55e857c76404 - <creusot::backend::clone_map::elaborator::ProgElab as creusot::backend::clone_map::elaborator::DepElab>::expand::h5668e4920f94c38a
                               at creusot/creusot/src/backend/clone_map/elaborator.rs:132:20
  40:     0x55e857c7976b - creusot::backend::clone_map::elaborator::Expander::expand::h419d44d50ca67d38
                               at creusot/creusot/src/backend/clone_map/elaborator.rs:349:21
  41:     0x55e857c79133 - creusot::backend::clone_map::elaborator::Expander::update_graph::h26ec795cbb0669b2
                               at creusot/creusot/src/backend/clone_map/elaborator.rs:330:13
  42:     0x55e857646de5 - creusot::backend::clone_map::Dependencies::provide_deps::he57fba83524616d3
                               at creusot/creusot/src/backend/clone_map.rs:378:35
  43:     0x55e857c68e4e - creusot::backend::program::translate_function::h833309c85b9465f2
                               at creusot/creusot/src/backend/program.rs:61:21
  44:     0x55e85764a6e0 - creusot::backend::Why3Generator::translate::hc0f1db556d7d7079
                               at creusot/creusot/src/backend.rs:74:28
  45:     0x55e8579c7cf3 - creusot::translation::after_analysis::h021969fa7d696e94
                               at creusot/creusot/src/translation.rs:122:17
  46:     0x55e85777d7fe - <creusot::callbacks::ToWhy as rustc_driver_impl::Callbacks>::after_expansion::{{closure}}::hdbdbe556a2d3e366
                               at creusot/creusot/src/callbacks.rs:124:21
  47:     0x55e8578fa1d6 - rustc_middle::ty::context::GlobalCtxt::enter::{{closure}}::h1117bbce5553e92f
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/compiler/rustc_middle/src/ty/context.rs:1336:37
  48:     0x55e857c9ef09 - rustc_middle::ty::context::tls::enter_context::{{closure}}::h8e3e6a616517111e
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/compiler/rustc_middle/src/ty/context/tls.rs:82:9
  49:     0x55e8575dbb26 - std::thread::local::LocalKey<T>::try_with::h70e9c04f6d8cf1aa
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/library/std/src/thread/local.rs:283:12
  50:     0x55e8578fa146 - std::thread::local::LocalKey<T>::with::h334e89ebcb8c4708
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/library/std/src/thread/local.rs:260:9
  51:     0x55e8578fa146 - rustc_middle::ty::context::tls::enter_context::h098ab98c8a074a44
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/compiler/rustc_middle/src/ty/context/tls.rs:79:9
  52:     0x55e8578fa146 - rustc_middle::ty::context::GlobalCtxt::enter::hd2a461b11739ec26
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/compiler/rustc_middle/src/ty/context.rs:1336:9
  53:     0x55e8579e83e7 - rustc_interface::queries::QueryResult<&rustc_middle::ty::context::GlobalCtxt>::enter::h00f6fa7b3f7d2861
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/compiler/rustc_interface/src/queries.rs:64:9
  54:     0x55e85775be02 - <creusot::callbacks::ToWhy as rustc_driver_impl::Callbacks>::after_expansion::h0de48eb0194db7fc
                               at creusot/creusot/src/callbacks.rs:120:17
  55:     0x7f1d40ff8fe4 - rustc_interface[4e0e22890ee77c79]::interface::run_compiler::<core[98a57322150ab76c]::result::Result<(), rustc_span[f405e44d3411febf]::ErrorGuaranteed>, rustc_driver_impl[3b5aaec34fa30fe1]::run_compiler::{closure#0}>::{closure#1}
  56:     0x7f1d40fdfbc9 - std[ceb29ca52b686cc8]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[4e0e22890ee77c79]::util::run_in_thread_with_globals<rustc_interface[4e0e22890ee77c79]::util::run_in_thread_pool_with_globals<rustc_interface[4e0e22890ee77c79]::interface::run_compiler<core[98a57322150ab76c]::result::Result<(), rustc_span[f405e44d3411febf]::ErrorGuaranteed>, rustc_driver_impl[3b5aaec34fa30fe1]::run_compiler::{closure#0}>::{closure#1}, core[98a57322150ab76c]::result::Result<(), rustc_span[f405e44d3411febf]::ErrorGuaranteed>>::{closure#0}, core[98a57322150ab76c]::result::Result<(), rustc_span[f405e44d3411febf]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[98a57322150ab76c]::result::Result<(), rustc_span[f405e44d3411febf]::ErrorGuaranteed>>
  57:     0x7f1d40fdf97a - <<std[ceb29ca52b686cc8]::thread::Builder>::spawn_unchecked_<rustc_interface[4e0e22890ee77c79]::util::run_in_thread_with_globals<rustc_interface[4e0e22890ee77c79]::util::run_in_thread_pool_with_globals<rustc_interface[4e0e22890ee77c79]::interface::run_compiler<core[98a57322150ab76c]::result::Result<(), rustc_span[f405e44d3411febf]::ErrorGuaranteed>, rustc_driver_impl[3b5aaec34fa30fe1]::run_compiler::{closure#0}>::{closure#1}, core[98a57322150ab76c]::result::Result<(), rustc_span[f405e44d3411febf]::ErrorGuaranteed>>::{closure#0}, core[98a57322150ab76c]::result::Result<(), rustc_span[f405e44d3411febf]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[98a57322150ab76c]::result::Result<(), rustc_span[f405e44d3411febf]::ErrorGuaranteed>>::{closure#1} as core[98a57322150ab76c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  58:     0x7f1d3b79911b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9002d9aae9b2170d
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/library/alloc/src/boxed.rs:2149:9
  59:     0x7f1d3b79911b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h444d2f27397e5994
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/library/alloc/src/boxed.rs:2149:9
  60:     0x7f1d3b79911b - std::sys::pal::unix::thread::Thread::new::thread_start::h041a15ab005af7ee
                               at /rustc/c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10/library/std/src/sys/pal/unix/thread.rs:108:17
  61:     0x7f1d3b468148 - start_thread
  62:     0x7f1d3b4ec0cc - __GI___clone3
  63:                0x0 - <unknown>


rustc version: 1.82.0-nightly (c1a6199e9 2024-07-24)
platform: x86_64-unknown-linux-gnu

query stack during panic:
end of query stack

It seems this happens because the string "unwrapped None" gets promoted to a static, which then tries to fetch the name of the closure via tcx.item_name in creusot/src/backend/dependency.rs:97.

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

1 participant