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

Compiler crashes when pretty-printing something #17824

Closed
tomwhoiscontrary opened this issue Oct 6, 2014 · 3 comments
Closed

Compiler crashes when pretty-printing something #17824

tomwhoiscontrary opened this issue Oct 6, 2014 · 3 comments
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@tomwhoiscontrary
Copy link
Contributor

I'm writing my first Rust program! It compiles, but when i try to pretty-print it with --pretty typed (because i'm trying to understand what types are being inferred), the compiler crashes.

I'm running rustc 0.11.0, which i got from Homebrew on a Mac running OS X 10.9.4 (uname -a says "Darwin hostname 13.3.0 Darwin Kernel Version 13.3.0: Tue Jun 3 21:27:35 PDT 2014; root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64").

Your bug report instructions mention that "It's also helpful to copy/paste the output of re-running the erroneous rustc command with the -v flag", but since the -v flag causes rustc to print its version and exit, i am skeptical of this claim.

The program:

use std::os;
use std::io::fs::File;

fn main() {
    let homedir = os::homedir().expect("the user's home directory could not be determined");
    let configFile = homedir.join(".cf").join("config.json");
    if (!configFile.is_file()) {
        fail!("the config file was not present at {}", configFile.display());
    }
    let mut reader = File::open(&configFile);
    let mut reader2 = reader.unwrap();
}

The command:

rustc --pretty typed bug.rs

The error message:

error: internal compiler error: node_id_to_type: no type for node `expr 2u (id=65)`
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'Box<Any>', /private/tmp/rust-GCum/rust-0.11.0/src/libsyntax/diagnostic.rs:162

The backtrace:

   1:        0x110d94b05 - rt::backtrace::imp::write::hc81110d3d6b7c73cmPp::v0.11.0
   2:        0x110d9b0a7 - failure::on_fail::hc762f23051f63e3fB5p::v0.11.0
   3:        0x111044b39 - unwind::begin_unwind_inner::hb6a32d9b8994b2c7VSd::v0.11.0
   4:        0x1104f7cb5 - unwind::begin_unwind::h5861459936587707106::v0.11.0
   5:        0x1104f86f1 - diagnostic::Handler::bug::h00cbb2b46927e612Occ::v0.11.0
   6:        0x10e03d658 - driver::session::Session::bug::hbd4edbf9f8728b2bd7q::v0.11.0
   7:        0x10e0a8483 - middle::ty::node_id_to_type::hd2dcd1f1b0daab8dZeQ::v0.11.0
   8:        0x10e9a663c - driver::driver::TypedAnnotation.pprust..PpAnn::post::hb005ba4b7c1e09879Cq::v0.11.0
   9:        0x1105f158f - print::pprust::State<'a>::print_expr::hd2e0783c67059bc44CO::v0.11.0
  10:        0x1105d7fc7 - print::pprust::State<'a>::print_type::hc1f48816ea321792DcN::v0.11.0
  11:        0x1105fe973 - print::pprust::State<'a>::print_item::h68221c863b8724aeMtN::v0.11.0
  12:        0x110626378 - print::pprust::State<'a>::print_decl::h255a31ea3fc557bfAzP::v0.11.0
  13:        0x1105f72ad - print::pprust::State<'a>::print_stmt::ha988aa3a01487a9eCkO::v0.11.0
  14:        0x110628ee2 - print::pprust::State<'a>::print_block_maybe_unclosed::head68fecb2760bf4ypO::v0.11.0
  15:        0x1105efae9 - print::pprust::State<'a>::print_expr::hd2e0783c67059bc44CO::v0.11.0
  16:        0x1106292ee - print::pprust::State<'a>::print_block_maybe_unclosed::head68fecb2760bf4ypO::v0.11.0
  17:        0x1105e8120 - print::pprust::State<'a>::print_expr::hd2e0783c67059bc44CO::v0.11.0
  18:        0x1105f76b4 - print::pprust::State<'a>::print_stmt::ha988aa3a01487a9eCkO::v0.11.0
  19:        0x110628ee2 - print::pprust::State<'a>::print_block_maybe_unclosed::head68fecb2760bf4ypO::v0.11.0
  20:        0x11062b88b - print::pprust::State<'a>::print_if::h645a71dc7a92f1c0cxO::v0.11.0
  21:        0x1105e4202 - print::pprust::State<'a>::print_expr::hd2e0783c67059bc44CO::v0.11.0
  22:        0x1105f70bb - print::pprust::State<'a>::print_stmt::ha988aa3a01487a9eCkO::v0.11.0
  23:        0x110628ee2 - print::pprust::State<'a>::print_block_maybe_unclosed::head68fecb2760bf4ypO::v0.11.0
  24:        0x1105fcb71 - print::pprust::State<'a>::print_item::h68221c863b8724aeMtN::v0.11.0
  25:        0x1105d1fa8 - print::pprust::State<'a>::print_mod::h55d21be51d16c410K7M::v0.11.0
  26:        0x1105d12f4 - print::pprust::print_crate::h18a6d1cb58730c1bGDM::v0.11.0
  27:        0x10e9a7734 - driver::driver::pretty_print_input::h3ca8fb5bb81001beVEq::v0.11.0
  28:        0x10e9c5b95 - driver::run_compiler::hd49ac6aa73bb72d3CDs::v0.11.0
  29:        0x10e9c5056 - driver::main_args::closure.101074
  30:        0x10e9d96db - task::TaskBuilder<S>::try_future::closure.102210
  31:        0x10e9d9574 - task::TaskBuilder<S>::spawn_internal::closure.102187
  32:        0x10dfd2c2c - task::spawn_opts::closure.7374
  33:        0x1110a73cc - rust_try
  34:        0x111040fda - unwind::try::h1dab452418dce7c3kHd::v0.11.0
  35:        0x111040cdc - task::Task::run::hac15d7c21261287acTc::v0.11.0
  36:        0x10dfd2abb - task::spawn_opts::closure.7319
  37:        0x111043849 - thread::thread_start::hde3a01c4bf3098cdKfd::v0.11.0
  38:     0x7fff8f812899 - _pthread_body
  39:     0x7fff8f81272a - _pthread_struct_init
@kmcallister kmcallister added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-pretty Area: Pretty printing (including `-Z unpretty`) labels Oct 7, 2014
@sfackler
Copy link
Member

Probably a dup of #17289

@goffrie
Copy link
Contributor

goffrie commented Feb 27, 2015

The sample program is a bit out of date now, but after updating it, I can't reproduce the bug.

@tamird
Copy link
Contributor

tamird commented Apr 22, 2015

Updated code:

#![feature(path_ext)]
use std::env;
use std::fs::{File, PathExt};

fn main() {
    let homedir = env::home_dir().expect("the user's home directory could not be determined");
    let configFile = homedir.join(".cf").join("config.json");
    if (!configFile.metadata().unwrap().is_file()) {
        println!("the config file was not present at {}", configFile.display());
    }
    let mut reader = File::open(&configFile);
    let mut reader2 = reader.unwrap();
}

Compiling with $ rustc -Z unstable-options --pretty typed main.rs no longer ICEs.

@alexcrichton alexcrichton added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Apr 22, 2015
lnicola pushed a commit to lnicola/rust that referenced this issue Aug 13, 2024
fix: Native diagnostics not working

              This should be a `continue` now

_Originally posted by `@Veykril` in rust-lang/rust-analyzer#17775 (comment)

I've tested the release compile output with IDE in the original PR, but my test workspace had only one `.rs` file 🤦 😢
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

7 participants