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

Clippy v0.0.191 with rustc 1.26.0-nightly (ae544ee1c 2018-03-29) causes ICE #2594

Closed
mati865 opened this issue Mar 30, 2018 · 12 comments
Closed
Assignees
Labels
I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@mati865
Copy link
Contributor

mati865 commented Mar 30, 2018

After upgrading clippy from 0.0.190 to 0.0.191 running cargo clippy causes ICE:

error: internal compiler error: librustc/ty/context.rs:502: node_id_to_type: no type for node `expr 10 (id=678)`

thread 'rustc' panicked at 'Box<Any>', librustc_errors/lib.rs:543:9

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.26.0-nightly (ae544ee1c 2018-03-29) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 --crate-type lib

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

error: Could not compile `hyper`.
warning: build failed, waiting for other jobs to finish...
error: build failed
stack backtrace:
   0:     0x7fcf1e07185b - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::he90736f0673c5957
                               at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1:     0x7fcf1e03f990 - std::sys_common::backtrace::print::h37226c664104fff7
                               at libstd/sys_common/backtrace.rs:71
                               at libstd/sys_common/backtrace.rs:59
   2:     0x7fcf1e06529d - std::panicking::default_hook::{{closure}}::h5edcec13387dd2e3
                               at libstd/panicking.rs:207
   3:     0x7fcf1e064ffb - std::panicking::default_hook::ha0061cec4ea60cf2
                               at libstd/panicking.rs:223
   4:     0x7fcf1f6ca5bd - core::ops::function::Fn::call::hfbcf24185d298f84
   5:     0x7fcf1e0657e9 - std::panicking::rust_panic_with_hook::hb876ad0773f5dc16
                               at libstd/panicking.rs:403
   6:     0x7fcf1e7c81b9 - std::panicking::begin_panic::hfdbd973f621df2dd
   7:     0x7fcf1e7e22c1 - rustc_errors::Handler::bug::h736866a11c15ee86
   8:     0x7fcf1f7bb18c - rustc::session::opt_span_bug_fmt::{{closure}}::hcc5093a6222a995e
   9:     0x7fcf1f7cf7d6 - rustc::ty::context::tls::with_opt::{{closure}}::hd62838ecc802308f
  10:     0x7fcf1f76bba3 - <std::thread::local::LocalKey<T>>::try_with::h704311228a5d19f8
  11:     0x7fcf1f75d1b6 - <std::thread::local::LocalKey<T>>::with::h34f8eb870dcd7b1d
  12:     0x7fcf1f57336d - rustc::ty::context::tls::with::h3eef14127bf48d9d
  13:     0x7fcf1f573bb9 - rustc::ty::context::tls::with_opt::h94f1de73e548f839
  14:     0x7fcf1f2b9204 - rustc::session::opt_span_bug_fmt::hb400c0f2e3c74341
  15:     0x7fcf1f2b9176 - rustc::session::bug_fmt::h425f210348cf2b49
  16:     0x7fcf1f56cf67 - rustc::ty::context::TypeckTables::expr_ty::he46e1d05b3c3a315
  17:     0x563b23076a5d - clippy_lints::consts::ConstEvalLateContext::expr::ha7d48722fdbf4df3
  18:     0x563b23076485 - clippy_lints::consts::constant_simple::he6f8268459cdfbe9
  19:     0x563b230f2dc4 - clippy_lints::utils::hir_utils::SpanlessHash::hash_expr::ha908ce311f08e295
  20:     0x563b230f30be - clippy_lints::utils::hir_utils::SpanlessHash::hash_expr::ha908ce311f08e295
  21:     0x563b230f32ae - clippy_lints::utils::hir_utils::SpanlessHash::hash_expr::ha908ce311f08e295
  22:     0x563b230beb17 - <clippy_lints::copies::CopyAndPaste as rustc::lint::LateLintPass<'a, 'tcx>>::check_expr::hfe6d820beccd7003
  23:     0x7fcf1f78f962 - <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr::he3c6cf91cbf47310
  24:     0x7fcf1f791d0a - <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_block::h1549a375ec49914c
  25:     0x7fcf1f78fa4c - <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr::he3c6cf91cbf47310
  26:     0x7fcf1f78e901 - <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_body::h47b6946ecc761425
  27:     0x7fcf1f78e717 - <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_nested_body::h8c7bbb4c4a61acd9
  28:     0x7fcf1f790221 - <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_fn::h4b58ef8ee757f8c0
  29:     0x7fcf1f6a45e6 - rustc::hir::intravisit::walk_impl_item::h8de7a2a1eed57e94
  30:     0x7fcf1f79355d - <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_impl_item::h4e63931920bc82c8
  31:     0x7fcf1f6a5aa8 - rustc::hir::intravisit::walk_impl_item_ref::h2d7c11fb9dd56a3b
  32:     0x7fcf1f67bf2e - rustc::hir::intravisit::walk_item::h7c736e7843580351
  33:     0x7fcf1f78ee4e - <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item::hcfa3c91da0fd72d4
  34:     0x7fcf1f79167d - <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod::h5ab7fd8abe3b9f59
  35:     0x7fcf1f67bd6c - rustc::hir::intravisit::walk_item::h7c736e7843580351
  36:     0x7fcf1f78ee4e - <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item::hcfa3c91da0fd72d4
  37:     0x7fcf1f79167d - <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod::h5ab7fd8abe3b9f59
  38:     0x7fcf1f67bd6c - rustc::hir::intravisit::walk_item::h7c736e7843580351
  39:     0x7fcf1f78ee4e - <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item::hcfa3c91da0fd72d4
  40:     0x7fcf1f79167d - <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod::h5ab7fd8abe3b9f59
  41:     0x7fcf1f67258c - rustc::hir::intravisit::walk_crate::h6cd18ca6d6e4862f
  42:     0x7fcf1f798d73 - rustc::lint::context::check_crate::h9af507c9f1d2c5ec
  43:     0x7fcf205a7b99 - <std::thread::local::LocalKey<T>>::with::h4c767a532ca41fa3
  44:     0x7fcf205ae136 - <std::thread::local::LocalKey<T>>::with::he47cefd74ff28307
  45:     0x7fcf2062459e - rustc::ty::context::TyCtxt::create_and_enter::hd599c2d32b176ac6
  46:     0x7fcf20521c37 - rustc_driver::driver::compile_input::hd12ba23060796bfe
  47:     0x7fcf205d6adf - rustc_driver::run_compiler_impl::h8ab3a92625df6f67
  48:     0x7fcf204fbb18 - syntax::with_globals::h5b93a0cb73c64078
  49:     0x7fcf205d5aaf - rustc_driver::run_compiler::hcca503a25e28737c
  50:     0x563b23043fde - std::sys_common::backtrace::__rust_begin_short_backtrace::h3a1b300b01f7b087
  51:     0x563b2304c30b - std::panicking::try::do_call::hde6ee9333deb8640
  52:     0x7fcf1e07febe - __rust_maybe_catch_panic
                               at libpanic_unwind/lib.rs:102
  53:     0x563b230486bd - <F as alloc::boxed::FnBox<A>>::call_box::hb74aeb5108e29d71
  54:     0x7fcf1e076f47 - std::sys_common::thread::start_thread::h5801fa5836ace044
                               at /checkout/src/liballoc/boxed.rs:793
                               at libstd/sys_common/thread.rs:24
  55:     0x7fcf1e045fb8 - std::sys::unix::thread::Thread::new::thread_start::h9ffd4ead1288775a
                               at libstd/sys/unix/thread.rs:90
  56:     0x7fcf1ddd108b - start_thread
  57:     0x7fcf1d8f1e7e - __GI___clone
  58:                0x0 - <unknown>
error: aborting due to previous error

Couldn't manage to reproduce it by anything different than cargo clippy.

Is this rustc or clippy bug (please close this issue if former)?

@oli-obk oli-obk added the I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ label Mar 30, 2018
@phansch
Copy link
Member

phansch commented Mar 30, 2018

Looks like the same as rust-lang/rust#49480

I don't know though whether it's a bug in clippy or rust.

@oli-obk
Copy link
Contributor

oli-obk commented Mar 30, 2018

node_id_to_type failures are usually due to us not using the correct tables. This mostly happens when using visitors. But without a backtrace it's hard to tell.

I'm kindof tracking this in #1976

@mati865
Copy link
Contributor Author

mati865 commented Mar 30, 2018

@oli-obk it might be not visible as github eats newlines after <details></details> but when you click on stack backtrace: you will see backtrace.

@phansch I saw it before but the error and trace are a bit different.

@mati865
Copy link
Contributor Author

mati865 commented Apr 3, 2018

Created SSCCE in this repo.
Quick reproducer:

git clone https://github.com/mati865/clippy-ice.git
cd clippy-ice
cargo clippy
#RUST_BACKTRACE=full cargo clippy 

@mati865
Copy link
Contributor Author

mati865 commented Apr 9, 2018

So the crash happens when clippy checks this line. I tried to reduce it but it stopped crashing...

I added few prints trying to understand it with formatting fun_name {:?} and it looks like that:

[irrelevant data]
ExprLit expr(22521: 0u32)
ExprLit expr(22527: 2usize)
ExprLit expr(22529: ' ')
ExprLit expr(22531: 0u32)
ExprRepeat expr(664: [0; ])
ExprLit expr(662: 0)
ExprLit expr(667: 0)
ExprRepeat expr(679: [httparse::EMPTY_HEADER; ])
ExprLit expr(678: 10)
error: internal compiler error: librustc/ty/context.rs:503: node_id_to_type: no type for node `expr 10 (id=678)`

Is there a way to make myself useful with this issue?

@oli-obk
Copy link
Contributor

oli-obk commented Apr 10, 2018

So it looks to me like the SpanlessHash does not take care to track the current body and body_tables. We probably just need to implement the visit_body method like we do inside our constant evaluator and then track the tables and make sure to feed those tables to any calls to simple_constant

@oherrala
Copy link

This looks like rust-lang/rust#49643

@severen
Copy link

severen commented May 5, 2018

I've also run into this myself on the latest release of Clippy (0.0.196) and nightly release of Rust (1.27.0-nightly (91db9dcf3 2018-05-04)).

Hopefully this is helpful (snipped out the output for compiling/checking each crate for posterity):

genesis* env RUST_BACKTRACE=1 cargo clippy
   Compiling version_check v0.1.3
<snip>
    Checking failure v0.1.1
error: internal compiler error: librustc/ty/context.rs:530: node_id_to_type: no type for node `expr 10 (id=678)`

thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:554:9
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:467
   6: std::panicking::begin_panic
   7: rustc_errors::Handler::bug
   8: rustc::session::opt_span_bug_fmt::{{closure}}
   9: rustc::ty::context::tls::with_opt::{{closure}}
  10: rustc::ty::context::tls::with_context_opt
  11: rustc::ty::context::tls::with_opt
  12: rustc::session::opt_span_bug_fmt
  13: rustc::session::bug_fmt
  14: rustc::ty::context::TypeckTables::expr_ty
  15: clippy_lints::consts::ConstEvalLateContext::expr
  16: clippy_lints::consts::constant_simple
  17: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  18: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  19: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  20: <clippy_lints::copies::CopyAndPaste as rustc::lint::LateLintPass<'a, 'tcx>>::check_expr
  21: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
  22: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_block
  23: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
  24: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_body
  25: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_nested_body
  26: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_fn
  27: rustc::hir::intravisit::walk_impl_item
  28: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_impl_item
  29: rustc::hir::intravisit::walk_impl_item_ref
  30: rustc::hir::intravisit::walk_item
  31: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  32: rustc::hir::intravisit::walk_mod
  33: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
  34: rustc::hir::intravisit::walk_item
  35: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  36: rustc::hir::intravisit::walk_mod
  37: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
  38: rustc::hir::intravisit::walk_item
  39: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  40: rustc::hir::intravisit::walk_mod
  41: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
  42: rustc::lint::context::check_crate
  43: rustc::ty::context::tls::enter_context
  44: <std::thread::local::LocalKey<T>>::with
  45: rustc::ty::context::TyCtxt::create_and_enter
  46: rustc_driver::driver::compile_input
  47: rustc_driver::run_compiler_impl
  48: <scoped_tls::ScopedKey<T>>::set
  49: syntax::with_globals
  50: rustc_driver::run_compiler
  51: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  52: std::panicking::try::do_call
  53: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  54: rustc_driver::run
  55: clippy_driver::main
  56: std::rt::lang_start::{{closure}}
  57: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  58: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  59: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:374
             at libstd/rt.rs:58
  60: main
  61: __libc_start_main
  62: _start
query stack during panic:
end of query stack
error: aborting due to previous error


note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.27.0-nightly (91db9dcf3 2018-05-04) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 --crate-type lib

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

error: Could not compile `hyper`.
warning: build failed, waiting for other jobs to finish...
error: build failed

@lorepozo
Copy link

lorepozo commented May 7, 2018

A minimal example depending on the rand crate is in rust-lang/rust#50484

lorepozo added a commit to lorepozo/program-induction that referenced this issue May 7, 2018
@phansch
Copy link
Member

phansch commented May 8, 2018

Going to take a look at the SpanlessHash panic

@phansch
Copy link
Member

phansch commented May 8, 2018

@mati865 I saw your comment just now, sorry. If you still want to tackle this, let me know and I will assign it to you. I essentially arrived at the same point where you were at and didn't have time to dig deeper, yet.

@mati865
Copy link
Contributor Author

mati865 commented May 8, 2018

@phansch I'd be happy if you could fix it.
I haven't got anywhere further and I won't have enough time for it.

afck added a commit to poanetwork/poa-ballot-stats that referenced this issue May 19, 2018
Clippy 0.0.202 fixes a bug that prevented using it here.
rust-lang/rust-clippy#2594
afck added a commit to poanetwork/poa-ballot-stats that referenced this issue May 19, 2018
Clippy 0.0.202 fixes a bug that prevented using it here.
rust-lang/rust-clippy#2594
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

6 participants