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 (maybe a clap.rs issue) #101625

Closed
FedX-sudo opened this issue Sep 9, 2022 · 5 comments
Closed

Internal Compiler Error (maybe a clap.rs issue) #101625

FedX-sudo opened this issue Sep 9, 2022 · 5 comments
Assignees
Labels
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.

Comments

@FedX-sudo
Copy link

Hi, I was working on a minum-viable clap.rs application when I found the following compiler level error. It occers in several configurations of a clap.rs program. I am running NixOS 22.10, but have also tried it in a containerized Arch Linux with the same result. I have even tried diferent Cargo and Clap versions to no avail. If you want more info, please let me know!

Code

use clap::{ Arg, Command};

fn main() {
    let m = Command::new("BubblePop")
        .arg(Arg::new("exe")
            .short('x')
            .takes_value(true)
            .value_name("exe")
            .required(true)
            .help("The program you wish to run"),
        )
        .get_matches();
    let cmd = m.subcommand_matches("exe").unwrap();
    println!("exe: {:?}", cmd);
}

Meta

rustc --version --verbose:

rustc 1.63.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.63.0
LLVM version: 14.0.6

Error output

   Compiling bubblepop v0.1.0 (/home/fedx/Code.new/bubblepop)
thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `82`,
 right: `1002111927320821928687967599834759150`', compiler/rustc_query_impl/src/on_disk_cache.rs:537:5
stack backtrace:
   0:     0x7ff0b0abbc7c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb16b437de6ab6276
   1:     0x7ff0b0b48f6e - core::fmt::write::h8f8bef23583ee234
   2:     0x7ff0b0ace771 - std::io::Write::write_fmt::h8486efe074824056
   3:     0x7ff0b0ade3ae - std::panicking::default_hook::{{closure}}::hdfa4615b29a34cb8
   4:     0x7ff0b0ade017 - std::panicking::default_hook::h60ffd169fe7df297
   5:     0x7ff0b122f246 - rustc_driver[94b7c8f27e2bcbcb]::DEFAULT_HOOK::{closure#0}::{closure#0}
   6:     0x7ff0b0adeb9e - std::panicking::rust_panic_with_hook::hf0183b899953e185
   7:     0x7ff0b0abd077 - std::panicking::begin_panic_handler::{{closure}}::h93eac1c61f0beba3
   8:     0x7ff0b0abc054 - std::sys_common::backtrace::__rust_end_short_backtrace::he4788588c206eaab
   9:     0x7ff0b0ade6c2 - rust_begin_unwind
  10:     0x7ff0b0a8f193 - core::panicking::panic_fmt::h20a31c8e90ca0d37
  11:     0x7ff0b0b48c08 - core::panicking::assert_failed_inner::hf66c161d34b90f62
  12:     0x7ff0b11277bb - core[96ac0df7930e2029]::panicking::assert_failed::<u128, u128>
  13:     0x7ff0b27ee215 - <rustc_query_impl[fd459d9260f0925b]::on_disk_cache::OnDiskCache as rustc_middle[8c52257da44c505]::ty::context::OnDiskCache>::new
  14:     0x7ff0b1352ece - rustc_incremental[609f0ce256b2be6f]::persist::load::load_query_result_cache::<rustc_query_impl[fd459d9260f0925b]::on_disk_cache::OnDiskCache>
  15:     0x7ff0b138d375 - <rustc_interface[14fbaa9386871f84]::queries::Queries>::global_ctxt
  16:     0x7ff0b1267088 - <rustc_interface[14fbaa9386871f84]::interface::Compiler>::enter::<rustc_driver[94b7c8f27e2bcbcb]::run_compiler::{closure#1}::{closure#2}, core[96ac0df7930e2029]::result::Result<core[96ac0df7930e2029]::option::Option<rustc_interface[14fbaa9386871f84]::queries::Linker>, rustc_errors[dc95ec35e6e31d9]::ErrorGuaranteed>>
  17:     0x7ff0b123c693 - rustc_span[7e77982d3a3b6b14]::with_source_map::<core[96ac0df7930e2029]::result::Result<(), rustc_errors[dc95ec35e6e31d9]::ErrorGuaranteed>, rustc_interface[14fbaa9386871f84]::interface::create_compiler_and_run<core[96ac0df7930e2029]::result::Result<(), rustc_errors[dc95ec35e6e31d9]::ErrorGuaranteed>, rustc_driver[94b7c8f27e2bcbcb]::run_compiler::{closure#1}>::{closure#1}>
  18:     0x7ff0b128a09b - std[8e9dabf04e886e9e]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[14fbaa9386871f84]::util::run_in_thread_pool_with_globals<rustc_interface[14fbaa9386871f84]::interface::run_compiler<core[96ac0df7930e2029]::result::Result<(), rustc_errors[dc95ec35e6e31d9]::ErrorGuaranteed>, rustc_driver[94b7c8f27e2bcbcb]::run_compiler::{closure#1}>::{closure#0}, core[96ac0df7930e2029]::result::Result<(), rustc_errors[dc95ec35e6e31d9]::ErrorGuaranteed>>::{closure#0}, core[96ac0df7930e2029]::result::Result<(), rustc_errors[dc95ec35e6e31d9]::ErrorGuaranteed>>
  19:     0x7ff0b128d269 - <<std[8e9dabf04e886e9e]::thread::Builder>::spawn_unchecked_<rustc_interface[14fbaa9386871f84]::util::run_in_thread_pool_with_globals<rustc_interface[14fbaa9386871f84]::interface::run_compiler<core[96ac0df7930e2029]::result::Result<(), rustc_errors[dc95ec35e6e31d9]::ErrorGuaranteed>, rustc_driver[94b7c8f27e2bcbcb]::run_compiler::{closure#1}>::{closure#0}, core[96ac0df7930e2029]::result::Result<(), rustc_errors[dc95ec35e6e31d9]::ErrorGuaranteed>>::{closure#0}, core[96ac0df7930e2029]::result::Result<(), rustc_errors[dc95ec35e6e31d9]::ErrorGuaranteed>>::{closure#1} as core[96ac0df7930e2029]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  20:     0x7ff0b0aedda3 - std::sys::unix::thread::Thread::new::thread_start::hee2dbea4fc5f0323
  21:     0x7ff0b08a4e86 - start_thread
  22:     0x7ff0b092bc60 - __clone3
  23:                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.63.0 running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
end of query stack
error: could not compile `bubblepop`
Backtrace

   Compiling bubblepop v0.1.0 (/home/fedx/Code.new/bubblepop)
    Finished dev [unoptimized + debuginfo] target(s) in 8.79s
     Running `target/debug/bubblepop -x test`
thread 'main' panicked at 'Argument or group `exe` used where a subcommand name was expected.', /home/fedx/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/clap-3.2.20/src/parser/matches/arg_matches.rs:1086:14
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: clap::parser::matches::arg_matches::ArgMatches::get_subcommand
             at /home/fedx/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/clap-3.2.20/src/parser/matches/arg_matches.rs:1358:17
   3: clap::parser::matches::arg_matches::ArgMatches::subcommand_matches
             at /home/fedx/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/clap-3.2.20/src/parser/matches/arg_matches.rs:1086:9
   4: bubblepop::main
             at ./src/main.rs:14:15
   5: core::ops::function::FnOnce::call_once
             at /build/rustc-1.63.0-src/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@FedX-sudo FedX-sudo 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 Sep 9, 2022
@BGR360
Copy link
Contributor

BGR360 commented Sep 12, 2022

Does the issue persist after doing a cargo clean? I notice that the OnDiskCache is involved in the backtrace, so perhaps it's a weird incremental compilation bug.

@FedX-sudo
Copy link
Author

In more testing it appears to be an issue with running builds outside a Nix sandbox. If I use a flake, and run nix build or nix run it compiles without issue.

@Enselic
Copy link
Member

Enselic commented Aug 18, 2023

Triage: Personally I am completely unfamiliar with Nix. Can you explain a bit more about under what circumstances the ICE occurs please? Does it still occur?

@Enselic
Copy link
Member

Enselic commented Oct 12, 2023

Triage: Closing as obsolete. Feel free to reopen if it turns out the problem still remains!

@Enselic Enselic closed this as not planned Won't fix, can't repro, duplicate, stale Oct 12, 2023
@saethlin saethlin self-assigned this Apr 29, 2024
@saethlin saethlin reopened this Apr 29, 2024
@saethlin
Copy link
Member

As far as I can tell, the ICE reported in this issue is caused by another process damaging rustc's build artifacts or by a buggy filesystem. That other process could be anything from an IDE running the compiler at the same time as a manual build to a find-and-replace that accidentally edits files in the target directory.

#124686 contains a mitigation for this situation; the compiler now has a crude way to detect and ignore damaged incremental compilation files. You will still get a warning about the damaged file, but the build should proceed normally. That change shipped in Rust 1.80 which released today, so I am closing this issue and a few others which as far as I can tell all have the same root cause. You shouldn't see this ICE anymore, but please file a new issue if you see something like it on 1.80 or later.

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. 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

No branches or pull requests

4 participants