Skip to content

Internal compiler error, very new to rust and rustc #108411

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Tuatarian opened this issue Feb 23, 2023 · 4 comments
Closed

Internal compiler error, very new to rust and rustc #108411

Tuatarian opened this issue Feb 23, 2023 · 4 comments
Labels
A-incr-comp Area: Incremental compilation 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

@Tuatarian
Copy link

Tuatarian commented Feb 23, 2023

Code

use std::fs;
use std::path::Path;
use std::str::{Split, from_utf8};
use std::vec;
use std::iter;
use std::collections::HashMap;

extern crate ahash;
use ahash::AHashMap;

enum TKind {
    IntLit, FloatLit, Ident, WSpace, StrLit, Punc, Op, PrefOp, Null
}

enum NKind {
    IntLit, FloatLit, Ident, Call, StrLit, Rt
}

pub fn main() {
    let prec_txt = fs::read_to_string(Path::new("../resources/precedence.txt")).unwrap();
    let prec_lines = prec_txt.split('\n').filter(|x| *x != "").collect::<Vec<&str>>();

    let sym_txt = fs::read_to_string(Path::new("../resources/symbols.txt")).unwrap();
    let syms = sym_txt.split('\n').collect::<Vec<&str>>();

    
    let whitespaces : Vec<char> = syms[2].split(',').map(|x| (*x).chars().nth(0).unwrap()).collect();
    let punc : Vec<char> = syms[0].split(',').map(|x| (*x).chars().nth(0).unwrap()).collect();
    let end_word : Vec<char> = whitespaces.iter().map(|x| *x).chain([',']).collect();
    let pref_ops : Vec<char> = syms[4].split(',').map(|x| (*x).chars().nth(0).unwrap()).collect();
    let ops : Vec<char> = prec_txt.split(['\n', ',']).filter(|x| x.len()  > 0).map(|x| x.chars().nth(0).unwrap()).collect();

    println!("{:?}", whitespaces);
    
    let precs : AHashMap<char, u32> = {
        let mut precs : AHashMap<char, u32> = AHashMap::new();
        for i in 0..prec_lines.len() {
            for o in prec_lines[i].chars() {
                if o != ',' {
                    precs.insert(o, (prec_lines.len() - i) as u32);
                }
            }
        }
        precs
    };

    let lex_stop : Vec<char> = ops.iter().map(|x| *x)
        .chain(pref_ops.iter().map(|x| *x))
        .chain(syms[1]
               .split(',')
               .filter(|x| x.len() > 0)
               .map(|x| (*x).chars().nth(0).unwrap()))
        .chain([',', '\n']).collect();
    
    println!("{:?}", partFile(&String::from(syms[6]), &lex_stop));
}

fn partFile(inp : &String, lex_stop : &Vec<char>) -> Vec<String> {
    let mut result : Vec<String> = Vec::new();
    let mut c_word : String = String::from("");
    for c in inp.chars() {
        if lex_stop.iter().any(|x| *x == c) {
            if c_word.len() != 0 {
                result.push(c_word);
            }
            result.push(String::from(c));
            c_word = String::from("");
        } else {
            c_word.push(c);
        }
    }
    if c_word.len() > 0 && lex_stop.iter().any(|x| *x == c_word.chars().nth(0).unwrap()) {
        result.push(c_word);
    }
    return result;
}

Meta

rustc --version --verbose:

rustup 1.25.2 (17db695f1 2023-02-01)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.67.1 (d5a82bbd2 2023-02-07)`

Error output

   Compiling Heaviside v0.1.0 (/home/tuatarian/code/Heaviside)
warning: unused imports: `Split`, `from_utf8`
 --> src/parlex.rs:3:16
  |
3 | use std::str::{Split, from_utf8};
  |                ^^^^^  ^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `std::vec`
 --> src/parlex.rs:4:5
  |
4 | use std::vec;
  |     ^^^^^^^^

warning: unused import: `std::iter`
 --> src/parlex.rs:5:5
  |
5 | use std::iter;
  |     ^^^^^^^^^

warning: unused import: `std::collections::HashMap`
 --> src/parlex.rs:6:5
  |
6 | use std::collections::HashMap;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^

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:     0x7f61c39656fa - std::backtrace_rs::backtrace::libunwind::trace::h79937bc171ada62c
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f61c39656fa - std::backtrace_rs::backtrace::trace_unsynchronized::h2292bca8571cb919
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f61c39656fa - std::sys_common::backtrace::_print_fmt::h9c461f248e4ae90d
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f61c39656fa - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he9fe6bf1a39182e1
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f61c39c825e - core::fmt::write::h032658c119c720d7
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/fmt/mod.rs:1208:17
   5:     0x7f61c3955a85 - std::io::Write::write_fmt::h299fc90dfae41c0d
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/io/mod.rs:1682:15
   6:     0x7f61c39654c5 - std::sys_common::backtrace::_print::heb70d25df9937e3f
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f61c39654c5 - std::sys_common::backtrace::print::had745c0a76b8b521
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f61c396820f - std::panicking::default_hook::{{closure}}::h1ea782cdfa2fd097
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:267:22
   9:     0x7f61c3967f4b - std::panicking::default_hook::h1cc3af63455a163c
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:286:9
  10:     0x7f61c6c60ab1 - <rustc_driver[5c3b90d1fb3964ba]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[e6a29f2585b3d454]::ops::function::FnOnce<(&core[e6a29f2585b3d454]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f61c3968a4d - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h6e4950ba7c0fd82a
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/alloc/src/boxed.rs:2032:9
  12:     0x7f61c3968a4d - std::panicking::rust_panic_with_hook::h5cafdc4b3bfd5528
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:692:13
  13:     0x7f61c39687c9 - std::panicking::begin_panic_handler::{{closure}}::hf31c60f40775892c
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:579:13
  14:     0x7f61c3965bac - std::sys_common::backtrace::__rust_end_short_backtrace::h28a5c7be595826cd
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/sys_common/backtrace.rs:137:18
  15:     0x7f61c39684d2 - rust_begin_unwind
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:575:5
  16:     0x7f61c39c4c43 - core::panicking::panic_fmt::h8fa27a0b37dd98b7
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/panicking.rs:64:14
  17:     0x7f61c515810f - rustc_mir_transform[6a2c2b2ce0179b78]::ffi_unwind_calls::has_ffi_unwind_calls
  18:     0x7f61c592966d - rustc_query_system[7dbbccfee5a2d054]::query::plumbing::try_load_from_disk_and_cache_in_memory::<rustc_query_impl[e214cefb6de2a99d]::plumbing::QueryCtxt, rustc_span[41a321a6411ba4fa]::def_id::LocalDefId, bool>
  19:     0x7f61c59286da - rustc_query_system[7dbbccfee5a2d054]::query::plumbing::try_execute_query::<rustc_query_impl[e214cefb6de2a99d]::plumbing::QueryCtxt, rustc_query_system[7dbbccfee5a2d054]::query::caches::VecCache<rustc_span[41a321a6411ba4fa]::def_id::LocalDefId, bool>>
  20:     0x7f61c592805c - <rustc_query_impl[e214cefb6de2a99d]::Queries as rustc_middle[83f907612b22699d]::ty::query::QueryEngine>::has_ffi_unwind_calls
  21:     0x7f61c5960b89 - <rustc_query_impl[e214cefb6de2a99d]::queries::has_ffi_unwind_calls as rustc_query_system[7dbbccfee5a2d054]::query::config::QueryConfig<rustc_query_impl[e214cefb6de2a99d]::plumbing::QueryCtxt>>::execute_query
  22:     0x7f61c6451d3e - <rustc_query_system[7dbbccfee5a2d054]::dep_graph::graph::DepGraph<rustc_middle[83f907612b22699d]::dep_graph::dep_node::DepKind>>::exec_cache_promotions::<rustc_middle[83f907612b22699d]::ty::context::TyCtxt>
  23:     0x7f61c6451b48 - <rustc_query_impl[e214cefb6de2a99d]::on_disk_cache::OnDiskCache as rustc_middle[83f907612b22699d]::ty::context::OnDiskCache>::drop_serialized_data
  24:     0x7f61c5e8711a - rustc_data_structures[1026114362f98086]::sync::join::<rustc_incremental[686a60493602ec2b]::persist::save::save_dep_graph::{closure#0}::{closure#2}, rustc_incremental[686a60493602ec2b]::persist::save::save_dep_graph::{closure#0}::{closure#3}, (), ()>
  25:     0x7f61c5e2204a - <rustc_middle[83f907612b22699d]::dep_graph::dep_node::DepKind as rustc_query_system[7dbbccfee5a2d054]::dep_graph::DepKind>::with_deps::<rustc_incremental[686a60493602ec2b]::persist::save::save_dep_graph::{closure#0}, ()>
  26:     0x7f61c5e21dea - <rustc_session[b89b9f24749004e7]::session::Session>::time::<(), <rustc_interface[65dcc5dffb099e04]::interface::Compiler>::enter<rustc_driver[5c3b90d1fb3964ba]::run_compiler::{closure#1}::{closure#2}, core[e6a29f2585b3d454]::result::Result<core[e6a29f2585b3d454]::option::Option<rustc_interface[65dcc5dffb099e04]::queries::Linker>, rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>::{closure#0}>
  27:     0x7f61c5e208bc - <rustc_interface[65dcc5dffb099e04]::interface::Compiler>::enter::<rustc_driver[5c3b90d1fb3964ba]::run_compiler::{closure#1}::{closure#2}, core[e6a29f2585b3d454]::result::Result<core[e6a29f2585b3d454]::option::Option<rustc_interface[65dcc5dffb099e04]::queries::Linker>, rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>
  28:     0x7f61c5e1b788 - rustc_span[41a321a6411ba4fa]::with_source_map::<core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>, rustc_interface[65dcc5dffb099e04]::interface::run_compiler<core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>, rustc_driver[5c3b90d1fb3964ba]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  29:     0x7f61c5e1b275 - <scoped_tls[393dd8f8fd825c8d]::ScopedKey<rustc_span[41a321a6411ba4fa]::SessionGlobals>>::set::<rustc_interface[65dcc5dffb099e04]::interface::run_compiler<core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>, rustc_driver[5c3b90d1fb3964ba]::run_compiler::{closure#1}>::{closure#0}, core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>
  30:     0x7f61c5e1a862 - std[359ab902947f5f0b]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[65dcc5dffb099e04]::util::run_in_thread_pool_with_globals<rustc_interface[65dcc5dffb099e04]::interface::run_compiler<core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>, rustc_driver[5c3b90d1fb3964ba]::run_compiler::{closure#1}>::{closure#0}, core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>
  31:     0x7f61c6513b7a - <<std[359ab902947f5f0b]::thread::Builder>::spawn_unchecked_<rustc_interface[65dcc5dffb099e04]::util::run_in_thread_pool_with_globals<rustc_interface[65dcc5dffb099e04]::interface::run_compiler<core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>, rustc_driver[5c3b90d1fb3964ba]::run_compiler::{closure#1}>::{closure#0}, core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e6a29f2585b3d454]::result::Result<(), rustc_errors[d24ea2395205e4f0]::ErrorGuaranteed>>::{closure#1} as core[e6a29f2585b3d454]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  32:     0x7f61c3972803 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb77d8d72ebcf79c4
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/alloc/src/boxed.rs:2000:9
  33:     0x7f61c3972803 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc08c3353e1568487
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/alloc/src/boxed.rs:2000:9
  34:     0x7f61c3972803 - std::sys::unix::thread::Thread::new::thread_start::h7168e596cd5e5ce6
                               at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/sys/unix/thread.rs:108:17
  35:     0x7f61c368cdcd - start_thread
  36:     0x7f61c3712630 - clone3
  37:                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.67.1 (d5a82bbd2 2023-02-07) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -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] checking if `parlex::main` contains FFI-unwind calls
end of query stack
warning: `Heaviside` (bin "Heaviside") generated 4 warnings
error: could not compile `Heaviside`; 4 warnings emitted
Backtrace

<backtrace>
can't seem to figure out how to do this

@Tuatarian Tuatarian 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 Feb 23, 2023
@Noratrieb
Copy link
Member

Did you try to cargo clean? And if yes, did that help?

@Tuatarian
Copy link
Author

Yes, and it did fix it

@workingjubilee workingjubilee added the A-incr-comp Area: Incremental compilation label Feb 24, 2023
@albertlarsan68
Copy link
Member

Fixed the formatting.

@cjgillot
Copy link
Contributor

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-incr-comp Area: Incremental compilation 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

Successfully merging a pull request may close this issue.

5 participants