Skip to content

Error emitted for compiling tests #105157

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

Closed
Laura7089 opened this issue Dec 2, 2022 · 4 comments
Closed

Error emitted for compiling tests #105157

Laura7089 opened this issue Dec 2, 2022 · 4 comments
Labels
C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Laura7089
Copy link
Contributor

I get a compiler panic when compiling the tests for Advent of Code solution.
cargo test emits the below error; nightly and beta don't.

Code

src/lib.rs:

#[macro_use]
extern crate aoc_runner_derive;
mod day1;

aoc_lib! { year = 2022 }

src/day1.rs:

#[aoc(day1, part1)]
fn solve_part1(input: &str) -> u32 {
    input
        .split("\n\n")
        .map(|elf| elf.split('\n').map(|c| c.parse::<u32>().unwrap()).sum())
        .max()
        .unwrap()
}

#[aoc(day1, part2)]
fn solve_part2(input: &str) -> u32 {
    todo!()
}

#[cfg(test)]
mod tests {
    use super::*;

    const SAMPLE_INPUT: &'static str = "1000
2000
3000

4000

5000
6000

7000
8000
9000

10000";

    #[test]
    fn part1_example() {
        assert_eq!(solve_part1(SAMPLE_INPUT), 73211);
    }
}

Meta

rustc --version --verbose:

rustc 1.65.0 (897e37553 2022-11-02)
binary: rustc
commit-hash: 897e37553bba8b42751c67658967889d11ecd120
commit-date: 2022-11-02
host: x86_64-unknown-linux-gnu
release: 1.65.0
LLVM version: 15.0.0

rustc +nightly --version --verbose:

rustc 1.67.0-nightly (96ddd32c4 2022-11-14)
binary: rustc
commit-hash: 96ddd32c4bfb1d78f0cd03eb068b1710a8cebeef
commit-date: 2022-11-14
host: x86_64-unknown-linux-gnu
release: 1.67.0-nightly
LLVM version: 15.0.4

rustc +beta --version --verbose:

rustc 1.66.0-beta.2 (0040709e3 2022-11-20)
binary: rustc
commit-hash: 0040709e39bfa159d099ee14628ad4ac72f91406
commit-date: 2022-11-20
host: x86_64-unknown-linux-gnu
release: 1.66.0-beta.2
LLVM version: 15.0.2

Error output

   Compiling aoc2022 v0.1.0 (/home/laura/source/advent/mine/aoc2022)
warning: unused variable: `input`
  --> src/day1.rs:11:16
   |
11 | fn solve_part2(input: &str) -> u32 {
   |                ^^^^^ help: if this is intentional, prefix it with an underscore: `_input`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: `aoc2022` (lib test) generated 1 warning
thread 'rustc' panicked at 'attempted to read from stolen value: rustc_middle::mir::Body', compiler/rustc_mir_transform/src/ffi_unwind_calls.rs:50:78
stack backtrace:
   0:     0x7f4cd096dd40 - std::backtrace_rs::backtrace::libunwind::trace::h32eb3e08e874dd27
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f4cd096dd40 - std::backtrace_rs::backtrace::trace_unsynchronized::haa3f451d27bc11a5
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f4cd096dd40 - std::sys_common::backtrace::_print_fmt::h5b94a01bb4289bb5
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f4cd096dd40 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb070b7fa7e3175df
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f4cd09c8bfe - core::fmt::write::hd5207aebbb9a86e9
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/fmt/mod.rs:1202:17
   5:     0x7f4cd095e935 - std::io::Write::write_fmt::h3bd699bbd129ab8a
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/io/mod.rs:1679:15
   6:     0x7f4cd09709f3 - std::sys_common::backtrace::_print::h7a21be552fdf58da
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f4cd09709f3 - std::sys_common::backtrace::print::ha85c41fe4dd80b13
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f4cd09709f3 - std::panicking::default_hook::{{closure}}::h04cca40023d0eeca
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:295:22
   9:     0x7f4cd09706df - std::panicking::default_hook::haa3ca8c310ed5402
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:314:9
  10:     0x7f4cd319e2e1 - rustc_driver[cfb34b1539811fe8]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f4cd097122d - std::panicking::rust_panic_with_hook::h7b190ce1a948faac
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:702:17
  12:     0x7f4cd0971087 - std::panicking::begin_panic_handler::{{closure}}::hbafbfdc3e1b97f68
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:588:13
  13:     0x7f4cd096e1ec - std::sys_common::backtrace::__rust_end_short_backtrace::hda93e5fef243b4c0
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7f4cd0970da2 - rust_begin_unwind
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:584:5
  15:     0x7f4cd09c57d3 - core::panicking::panic_fmt::h8d17ca1073d9a733
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/panicking.rs:142:14
  16:     0x7f4cd3020efc - rustc_mir_transform[de1f68ec5b9668bc]::ffi_unwind_calls::has_ffi_unwind_calls
  17:     0x7f4cd283088c - rustc_query_system[860ed7b39cdfb46b]::query::plumbing::try_load_from_disk_and_cache_in_memory::<rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt, rustc_span[8f00505efff112e2]::def_id::LocalDefId, bool>
  18:     0x7f4cd282fb8e - rustc_query_system[860ed7b39cdfb46b]::query::plumbing::try_execute_query::<rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt, rustc_query_system[860ed7b39cdfb46b]::query::caches::DefaultCache<rustc_span[8f00505efff112e2]::def_id::LocalDefId, bool>>
  19:     0x7f4cd30dd4fe - <rustc_query_impl[d6191eea714bd250]::Queries as rustc_middle[a9ca1c3f9fd197cd]::ty::query::QueryEngine>::has_ffi_unwind_calls
  20:     0x7f4cd302194b - rustc_mir_transform[de1f68ec5b9668bc]::ffi_unwind_calls::required_panic_strategy
  21:     0x7f4cd2ed1c2d - <rustc_query_system[860ed7b39cdfb46b]::dep_graph::graph::DepGraph<rustc_middle[a9ca1c3f9fd197cd]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[a9ca1c3f9fd197cd]::ty::context::TyCtxt, rustc_span[8f00505efff112e2]::def_id::CrateNum, core[8c92e53db3fc2eaa]::option::Option<rustc_target[c2a7a196ebbcf63b]::spec::PanicStrategy>>
  22:     0x7f4cd2ed0cce - rustc_query_system[860ed7b39cdfb46b]::query::plumbing::try_execute_query::<rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt, rustc_query_system[860ed7b39cdfb46b]::query::caches::DefaultCache<rustc_span[8f00505efff112e2]::def_id::CrateNum, core[8c92e53db3fc2eaa]::option::Option<rustc_target[c2a7a196ebbcf63b]::spec::PanicStrategy>>>
  23:     0x7f4cd2ed04a0 - rustc_query_system[860ed7b39cdfb46b]::query::plumbing::get_query::<rustc_query_impl[d6191eea714bd250]::queries::required_panic_strategy, rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt>
  24:     0x7f4cd252d5fb - <rustc_metadata[d8be3da67d4a4339]::rmeta::encoder::EncodeContext>::encode_crate_root
  25:     0x7f4cd20bac42 - rustc_metadata[d8be3da67d4a4339]::rmeta::encoder::encode_metadata_impl
  26:     0x7f4cd209d64e - rustc_data_structures[62ce3989ce8140ee]::sync::join::<rustc_metadata[d8be3da67d4a4339]::rmeta::encoder::encode_metadata::{closure#0}, rustc_metadata[d8be3da67d4a4339]::rmeta::encoder::encode_metadata::{closure#1}, (), ()>
  27:     0x7f4cd209d539 - rustc_metadata[d8be3da67d4a4339]::rmeta::encoder::encode_metadata
  28:     0x7f4cd209c623 - rustc_metadata[d8be3da67d4a4339]::fs::encode_and_write_metadata
  29:     0x7f4cd2090342 - <rustc_interface[3182dd864eff9d7d]::passes::QueryContext>::enter::<<rustc_interface[3182dd864eff9d7d]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<alloc[188ed69dc0d14b4b]::boxed::Box<dyn core[8c92e53db3fc2eaa]::any::Any>, rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>
  30:     0x7f4cd204fe73 - <rustc_interface[3182dd864eff9d7d]::queries::Queries>::ongoing_codegen
  31:     0x7f4cd204e2ca - rustc_interface[3182dd864eff9d7d]::interface::create_compiler_and_run::<core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>, rustc_driver[cfb34b1539811fe8]::run_compiler::{closure#1}>
  32:     0x7f4cd204cac1 - <scoped_tls[e395fa6e23b19669]::ScopedKey<rustc_span[8f00505efff112e2]::SessionGlobals>>::set::<rustc_interface[3182dd864eff9d7d]::interface::run_compiler<core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>, rustc_driver[cfb34b1539811fe8]::run_compiler::{closure#1}>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>
  33:     0x7f4cd204c7af - std[71cb4861428b0c25]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3182dd864eff9d7d]::util::run_in_thread_pool_with_globals<rustc_interface[3182dd864eff9d7d]::interface::run_compiler<core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>, rustc_driver[cfb34b1539811fe8]::run_compiler::{closure#1}>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>
  34:     0x7f4cd3001d70 - <<std[71cb4861428b0c25]::thread::Builder>::spawn_unchecked_<rustc_interface[3182dd864eff9d7d]::util::run_in_thread_pool_with_globals<rustc_interface[3182dd864eff9d7d]::interface::run_compiler<core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>, rustc_driver[cfb34b1539811fe8]::run_compiler::{closure#1}>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>::{closure#1} as core[8c92e53db3fc2eaa]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  35:     0x7f4cd097b003 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h49f797984e2121bf
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/alloc/src/boxed.rs:1940:9
  36:     0x7f4cd097b003 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hfa4f3d0ee6440e0b
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/alloc/src/boxed.rs:1940:9
  37:     0x7f4cd097b003 - std::sys::unix::thread::Thread::new::thread_start::h62ca48b42d48a8fc
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys/unix/thread.rs:108:17
  38:     0x7f4cd06d28fd - <unknown>
  39:     0x7f4cd0754a60 - <unknown>
  40:                0x0 - <unknown>

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.65.0 (897e37553 2022-11-02) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

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

query stack during panic:
#0 [has_ffi_unwind_calls] check if `day1::day1_part1::<impl at src/day1.rs:1:1: 1:20>::day1_part1` contains FFI-unwind calls
#1 [required_panic_strategy] query a crate's required panic strategy
end of query stack
warning: `aoc2022` (lib) generated 1 warning (1 duplicate)
error: could not compile `aoc2022`; 1 warning emitted
Backtrace

   Compiling aoc2022 v0.1.0 (/home/laura/source/advent/mine/aoc2022)
warning: unused variable: `input`
  --> src/day1.rs:11:16
   |
11 | fn solve_part2(input: &str) -> u32 {
   |                ^^^^^ help: if this is intentional, prefix it with an underscore: `_input`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: `aoc2022` (lib test) generated 1 warning
thread 'rustc' panicked at 'attempted to read from stolen value: rustc_middle::mir::Body', compiler/rustc_mir_transform/src/ffi_unwind_calls.rs:50:78
stack backtrace:
   0: rust_begin_unwind
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/panicking.rs:142:14
   2: rustc_mir_transform::ffi_unwind_calls::has_ffi_unwind_calls
   3: rustc_query_system::query::plumbing::try_load_from_disk_and_cache_in_memory::<rustc_query_impl::plumbing::QueryCtxt, rustc_span::def_id::LocalDefId, bool>
   4: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, bool>>
   5: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::has_ffi_unwind_calls
   6: rustc_mir_transform::ffi_unwind_calls::required_panic_strategy
   7: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::CrateNum, core::option::Option<rustc_target::spec::PanicStrategy>>
   8: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::CrateNum, core::option::Option<rustc_target::spec::PanicStrategy>>>
   9: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::required_panic_strategy, rustc_query_impl::plumbing::QueryCtxt>
  10: <rustc_metadata::rmeta::encoder::EncodeContext>::encode_crate_root
  11: rustc_metadata::rmeta::encoder::encode_metadata_impl
  12: rustc_data_structures::sync::join::<rustc_metadata::rmeta::encoder::encode_metadata::{closure#0}, rustc_metadata::rmeta::encoder::encode_metadata::{closure#1}, (), ()>
  13: rustc_metadata::rmeta::encoder::encode_metadata
  14: rustc_metadata::fs::encode_and_write_metadata
  15: <rustc_interface::passes::QueryContext>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_errors::ErrorGuaranteed>>
  16: <rustc_interface::queries::Queries>::ongoing_codegen
  17: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>
  18: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
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.65.0 (897e37553 2022-11-02) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

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

query stack during panic:
#0 [has_ffi_unwind_calls] check if `day1::day1_part1::<impl at src/day1.rs:1:1: 1:20>::day1_part1` contains FFI-unwind calls
#1 [required_panic_strategy] query a crate's required panic strategy
end of query stack
warning: `aoc2022` (lib) generated 1 warning (1 duplicate)
error: could not compile `aoc2022`; 1 warning emitted

@Laura7089 Laura7089 added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 2, 2022
@JohnTitor JohnTitor added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Jan 14, 2023
@langston-barrett
Copy link
Contributor

I was unable to reproduce this by cloning this repo, going into aoc2022 and setting up lib.rs and day1.rs as indicated.

@Laura7089 Are you still able to reproduce this? Can you post a standalone example?

@cjgillot
Copy link
Contributor

Very likely fixed by #108820, but we don't have a test for it unfortunately.

@Laura7089
Copy link
Contributor Author

Laura7089 commented Mar 19, 2023

I've checked out 8ce3871 of the repo, and setup src/lib.rs and src/day1.rs as I indicated, but I'm unable to reproduce the bug with either latest stable (rustc 1.68.0 (2c8cc3432 2023-03-06)) or the version in the post (backdated with rustup install 1.65 and cargo +1.65 test).

Unfortunately I don't think I have any revision in that repo which produced this error :( . Additionally, since Cargo.lock isn't checked into the repo, I can't guarantee I have the same dep tree as before.

@cjgillot
Copy link
Contributor

Marking as fixed by #108820. Please open a new instance of this bug if it appears again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants