-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
error: internal compiler error: src/librustc/ty/context.rs:248 "node {} with HirId::owner {:?} cannot be placed in TypeckTables with local_id_root {:?}" #57298
Comments
It's being tracked in rust-lang/rust-clippy#3629 |
…hansch Add itertools to integration tests Mainly because it causes an ICE in rust-lang/rust#57298 and it's a good library to test anyway.
Ok, so I wanted to say the following(and close the issue) but I'm now no longer sure... but instead of deleting all this text and not posting this, i am posting it, but I'm not closing the issue. So consider this undeleted :D I've since updated and recompiled I've tried using the same commit of
I guess I can close this now, unless someone thinks this ICE can happen in cases unrelated to EDIT: ok I even tested an earlier clippy commit 756b32e1e2ad474097f8d3e510b319dd5023297d to still not ICE, therefore it must be that |
@xftroxgpx this is actually very useful info. |
Is this still happening with debug-assertions enabled? I was unable to repro with Environment: I also tried rust-clippy@8ac411dd42c6612b3184d305f9426e7e364cb211 |
You should try with Clippy commit |
Very sorry I messed up that first PR @xftroxgpx XD People should stop asking me for changes on git |
@Lokathor no worries :) I couldn't have done it either - I've no idea what's happening there either way :D |
I applied #57435 manually and then tested: I can confirm that the issue is fixed! (ie. latest env$ rustc -vV
!! LD_LIBRARY_PATH=/home/xftroxgpx/build/2nonpkgs/rust.stuff/rust/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib:/home/xftroxgpx/build/2nonpkgs/rust.stuff/rust/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib:/home/xftroxgpx/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib:/home/xftroxgpx/build/2nonpkgs/rust.stuff/rust/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib:/home/xftroxgpx/build/2nonpkgs/rust.stuff/rust/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib:/home/xftroxgpx/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib:
!! Executing '/home/xftroxgpx/build/2nonpkgs/rust.stuff/rust/rust/build//x86_64-unknown-linux-gnu/stage2/bin//rustc' in pwd='/home/xftroxgpx/build/2nonpkgs/rust.stuff/rust' with args: '-vV'
rustc 1.33.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.33.0-dev
LLVM version: 8.0
/home/xftroxgpx/build/2nonpkgs/rust.stuff/rust/rust
$ git describe --all --long
heads/master-0-g9d54812829
/home/xftroxgpx/build/2nonpkgs/rust.stuff/rust-clippy
$ git describe --all --long
heads/master-0-g5b849660
$ cargo -vV
!! LD_LIBRARY_PATH=/home/xftroxgpx/build/2nonpkgs/rust.stuff/rust/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib:/home/xftroxgpx/build/2nonpkgs/rust.stuff/rust/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib:/home/xftroxgpx/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib:/home/xftroxgpx/build/2nonpkgs/rust.stuff/rust/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib:/home/xftroxgpx/build/2nonpkgs/rust.stuff/rust/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib:/home/xftroxgpx/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib:
!! Executing '/home/xftroxgpx/build/2nonpkgs/rust.stuff/cargo/cargo//target/release//cargo' in pwd='/home/xftroxgpx/build/2nonpkgs/rust.stuff/rust-clippy' with args: '-vV'
cargo 1.33.0-dev (a62e36b4 2019-01-06)
release: 1.33.0
commit-hash: a62e36b4417cbf872960eda156130da932fb765d
commit-date: 2019-01-06
had compiled rustc with this failed to compile(see below), but I guess it doesn't matter since it's an earlier commit and it just works with the latest one instead.
|
FWIW I tested clippy @ |
@dlrobertson
But this doesn't matter since it worked with the newer/later commit ;-) |
It matters because there is only workaround for the bug, fixing it would be better. |
@mati865 I meant: it doesn't matter that it error-ed with clippy commit |
Wait, so you're actually saying that the ICE doesn't happen anymore because clippy did a workaround for it? (instead of something in rustc having been fixed since then?) So that means that with the same clippy commit from OP, I should be able to reproduce the ICE, trying: I'm getting unrelated errors:
All that got fixed by clippy commit: rust-lang/rust-clippy@756b32e which I've tried too:
|
Clippy removed lint that was causing ICE. It's still unknown if it was bug in the lint or in Rust. It'd be great to readd it when it works.
|
Confirmed the ICE still happens: $ time RUST_BACKTRACE=1 ./target/debug/cargo-clippy
!! LD_LIBRARY_PATH=/home/xftroxgpx/build/2nonpkgs/rust.stuff/rust/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib:/home/xftroxgpx/build/2nonpkgs/rust.stuff/rust/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib:/home/xftroxgpx/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib:/home/xftroxgpx/build/2nonpkgs/rust.stuff/rust/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib:/home/xftroxgpx/build/2nonpkgs/rust.stuff/rust/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib:/home/xftroxgpx/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib:
!! Executing '/home/xftroxgpx/build/2nonpkgs/rust.stuff/cargo/cargo//target/release//cargo' in pwd='/home/xftroxgpx/build/2nonpkgs/rust.stuff/rust-clippy' with args: 'check'
Checking unicode-normalization v0.1.7
Checking regex-syntax v0.6.4
Checking thread_local v0.3.6
Checking itertools v0.7.11
error: internal compiler error: src/librustc/ty/context.rs:246: node type $crate::lazy::Lazy<Mutex<ThreadIdManager>> (id=2800) with HirId::owner DefId(0/0:134 ~ thread_local[6342]::thread_id[0]::{{impl}}[3]::deref[0]::__stability[0]::LAZY[0]) cannot be placed in TypeckTables with local_id_root DefId(0/0:131 ~ thread_local[6342]::thread_id[0]::{{impl}}[3]::deref[0]::__stability[0])
thread '<unnamed>' panicked at 'Box<Any>', src/librustc_errors/lib.rs:590:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
1: std::sys_common::backtrace::print
2: std::panicking::default_hook::{{closure}}
3: std::panicking::default_hook
4: rustc::util::common::panic_hook
5: std::panicking::rust_panic_with_hook
6: std::panicking::begin_panic
7: rustc_errors::Handler::bug
8: rustc::util::bug::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::util::bug::opt_span_bug_fmt
13: rustc::util::bug::bug_fmt
14: rustc::ty::context::validate_hir_id_for_typeck_tables::{{closure}}
15: rustc::ty::context::tls::with::{{closure}}
16: rustc::ty::context::tls::with_context::{{closure}}
17: rustc::ty::context::tls::with_context_opt
18: rustc::ty::context::tls::with_context
19: rustc::ty::context::tls::with
20: rustc::ty::context::TypeckTables::node_id_to_type_opt
21: <clippy_lints::random_state::Pass as rustc::lint::LateLintPass<'a, 'tcx>>::check_ty
at /home/xftroxgpx/build/2nonpkgs/rust.stuff/rust-clippy/clippy_lints/src/random_state.rs:38
22: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_ty
23: rustc::hir::intravisit::walk_item
24: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::lint::context::LintContext<'tcx>>::with_lint_attrs
25: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
26: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_decl
27: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_stmt
28: rustc::hir::intravisit::walk_block
29: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_block
30: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::lint::context::LintContext<'tcx>>::with_lint_attrs
31: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
32: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_body
33: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_nested_body
34: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_fn
35: rustc::hir::intravisit::walk_item
36: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::lint::context::LintContext<'tcx>>::with_lint_attrs
37: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
38: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_decl
39: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_stmt
40: rustc::hir::intravisit::walk_block
41: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_block
42: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::lint::context::LintContext<'tcx>>::with_lint_attrs
43: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
44: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_body
45: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_nested_body
46: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_fn
47: rustc::hir::intravisit::walk_impl_item
48: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::lint::context::LintContext<'tcx>>::with_lint_attrs
49: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_impl_item
50: rustc::hir::intravisit::walk_impl_item_ref
51: rustc::hir::intravisit::walk_item
52: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::lint::context::LintContext<'tcx>>::with_lint_attrs
53: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
54: rustc::hir::intravisit::walk_mod
55: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
56: rustc::hir::intravisit::walk_item
57: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::lint::context::LintContext<'tcx>>::with_lint_attrs
58: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
59: rustc::hir::intravisit::walk_mod
60: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
61: rustc::hir::intravisit::walk_crate
62: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::lint::context::LintContext<'tcx>>::with_lint_attrs
63: rustc::lint::context::check_crate
64: rustc::util::common::time
65: rustc_rayon_core::tlv::with
66: <std::thread::local::LocalKey<T>>::with
67: rustc::ty::context::tls::enter_global
68: rustc::ty::context::TyCtxt::create_and_enter
69: rustc_driver::driver::phase_3_run_analysis_passes
70: rustc_driver::driver::compile_input
71: rustc_driver::run_compiler_with_pool
72: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
73: std::panicking::try::do_call
74: __rust_maybe_catch_panic
75: std::panicking::try
76: std::panic::catch_unwind
77: rustc_rayon_core::unwind::halt_unwinding
78: <rustc_rayon_core::job::StackJob<L, F, R> as rustc_rayon_core::job::Job>::execute
79: rustc_rayon_core::registry::WorkerThread::wait_until_cold
80: rustc_rayon_core::registry::main_loop::{{closure}}
81: <scoped_tls::ScopedKey<T>>::set
82: <std::thread::local::LocalKey<T>>::with
83: <scoped_tls::ScopedKey<T>>::set
84: rustc_rayon_core::thread_pool::ThreadPool::scoped_pool::{{closure}}
85: __rust_maybe_catch_panic
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.33.0-dev (9d5481282 2019-01-08) 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 `thread_local`.
warning: build failed, waiting for other jobs to finish...
^C Building [=============================> ] 62/114
real 0m5.080s
user 0m0.003s
sys 0m0.001s it happens because I undid the workaround that clippy applied to avoid this ICE(ie. brought back diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs
index 35c00fb6..4a5972f8 100644
--- a/clippy_lints/src/lib.rs
+++ b/clippy_lints/src/lib.rs
@@ -180,6 +180,7 @@ pub mod precedence;
pub mod ptr;
pub mod ptr_offset_with_cast;
pub mod question_mark;
+pub mod random_state;
pub mod ranges;
pub mod redundant_clone;
pub mod redundant_field_names;
@@ -486,6 +487,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
reg.register_late_lint_pass(box ptr_offset_with_cast::Pass);
reg.register_late_lint_pass(box redundant_clone::RedundantClone);
reg.register_late_lint_pass(box slow_vector_initialization::Pass);
+ reg.register_late_lint_pass(box random_state::Pass);
reg.register_late_lint_pass(box types::RefToMut);
reg.register_lint_group("clippy::restriction", Some("clippy_restriction"), vec![
@@ -1028,6 +1030,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
fallible_impl_from::FALLIBLE_IMPL_FROM,
mutex_atomic::MUTEX_INTEGER,
needless_borrow::NEEDLESS_BORROW,
+ random_state::RANDOM_STATE,
redundant_clone::REDUNDANT_CLONE,
unwrap::PANICKING_UNWRAP,
unwrap::UNNECESSARY_UNWRAP,
diff --git a/clippy_lints/src/random_state.rs b/clippy_lints/src/random_state.rs
new file mode 100644
index 00000000..930733d7
--- /dev/null
+++ b/clippy_lints/src/random_state.rs
@@ -0,0 +1,51 @@
+use crate::utils::{match_type, paths, span_lint};
+use rustc::hir::Ty;
+use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
+use rustc::ty::subst::UnpackedKind;
+use rustc::ty::TyKind;
+use rustc::{declare_tool_lint, lint_array};
+
+/// **What it does:** Checks for usage of `RandomState`
+///
+/// **Why is this bad?** Some applications don't need collision prevention
+/// which lowers the performance.
+///
+/// **Known problems:** None.
+///
+/// **Example:**
+/// ```rust
+/// fn x() {
+/// let mut map = std::collections::HashMap::new();
+/// map.insert(3, 4);
+/// }
+/// ```
+declare_clippy_lint! {
+ pub RANDOM_STATE,
+ nursery,
+ "use of RandomState"
+}
+
+pub struct Pass;
+
+impl LintPass for Pass {
+ fn get_lints(&self) -> LintArray {
+ lint_array!(RANDOM_STATE)
+ }
+}
+
+impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
+ fn check_ty(&mut self, cx: &LateContext<'a, 'tcx>, ty: &Ty) {
+ if let Some(tys) = cx.tables.node_id_to_type_opt(ty.hir_id) {
+ if let TyKind::Adt(_, substs) = tys.sty {
+ for subst in substs {
+ if let UnpackedKind::Type(build_hasher) = subst.unpack() {
+ if match_type(cx, build_hasher, &paths::RANDOM_STATE) {
+ span_lint(cx, RANDOM_STATE, ty.span, "usage of RandomState");
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
diff --git a/clippy_lints/src/utils/paths.rs b/clippy_lints/src/utils/paths.rs
index 0779d779..0ec684e3 100644
--- a/clippy_lints/src/utils/paths.rs
+++ b/clippy_lints/src/utils/paths.rs
@@ -73,6 +73,7 @@ pub const PATH_BUF: [&str; 3] = ["std", "path", "PathBuf"];
pub const PATH_TO_PATH_BUF: [&str; 4] = ["std", "path", "Path", "to_path_buf"];
pub const PTR_NULL: [&str; 2] = ["ptr", "null"];
pub const PTR_NULL_MUT: [&str; 2] = ["ptr", "null_mut"];
+pub const RANDOM_STATE: [&str; 5] = ["std", "collections", "hash", "map", "RandomState"];
pub const RANGE: [&str; 3] = ["core", "ops", "Range"];
pub const RANGE_ARGUMENT_TRAIT: [&str; 3] = ["core", "ops", "RangeBounds"];
pub const RANGE_FROM: [&str; 3] = ["core", "ops", "RangeFrom"];
diff --git a/tests/run-pass/used_underscore_binding_macro.rs b/tests/run-pass/used_underscore_binding_macro.rs
index 8b6c6557..dc590cbc 100644
--- a/tests/run-pass/used_underscore_binding_macro.rs
+++ b/tests/run-pass/used_underscore_binding_macro.rs
@@ -8,6 +8,7 @@
// except according to those terms.
#![allow(clippy::useless_attribute)] //issue #2910
+#![allow(clippy::random_state)]
#[macro_use]
extern crate serde_derive;
diff --git a/tests/ui/random_state.rs b/tests/ui/random_state.rs
new file mode 100644
index 00000000..9f278ecc
--- /dev/null
+++ b/tests/ui/random_state.rs
@@ -0,0 +1,20 @@
+#![warn(clippy::random_state)]
+
+use std::collections::hash_map::RandomState;
+use std::collections::hash_map::{DefaultHasher, HashMap};
+use std::hash::BuildHasherDefault;
+
+fn main() {
+ // Should warn
+ let mut map = HashMap::new();
+ map.insert(3, 4);
+ let mut map = HashMap::with_hasher(RandomState::new());
+ map.insert(true, false);
+ let _map: HashMap<_, _> = vec![(2, 3)].into_iter().collect();
+ let _vec: Vec<HashMap<i32, i32>>;
+ // Shouldn't warn
+ let _map: HashMap<i32, i32, BuildHasherDefault<DefaultHasher>> = HashMap::default();
+ let mut map = HashMap::with_hasher(BuildHasherDefault::<DefaultHasher>::default());
+ map.insert("a", "b");
+}
+
diff --git a/tests/ui/random_state.stderr b/tests/ui/random_state.stderr
new file mode 100644
index 00000000..df224bf0
--- /dev/null
+++ b/tests/ui/random_state.stderr
@@ -0,0 +1,28 @@
+error: usage of RandomState
+ --> $DIR/random_state.rs:9:19
+ |
+LL | let mut map = HashMap::new();
+ | ^^^^^^^^^^^^
+ |
+ = note: `-D clippy::random-state` implied by `-D warnings`
+
+error: usage of RandomState
+ --> $DIR/random_state.rs:11:19
+ |
+LL | let mut map = HashMap::with_hasher(RandomState::new());
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: usage of RandomState
+ --> $DIR/random_state.rs:13:15
+ |
+LL | let _map: HashMap<_, _> = vec![(2, 3)].into_iter().collect();
+ | ^^^^^^^^^^^^^
+
+error: usage of RandomState
+ --> $DIR/random_state.rs:14:19
+ |
+LL | let _vec: Vec<HashMap<i32, i32>>;
+ | ^^^^^^^^^^^^^^^^^
+
+error: aborting due to 4 previous errors
+ (the above is to be applied on current rustc/cargo used
rustc's compile-time also tested with even newer rustc:
|
ICE has the same message as the following: That is, this message: /// Validate that the given HirId (respectively its `local_id` part) can be
/// safely used as a key in the tables of a TypeckTable. For that to be
/// the case, the HirId must have the same `owner` as all the other IDs in
/// this table (signified by `local_id_root`). Otherwise the HirId
/// would be in a different frame of reference and using its `local_id`
/// would result in lookup errors, or worse, in silently wrong data being
/// stored/returned.
fn validate_hir_id_for_typeck_tables(local_id_root: Option<DefId>,
hir_id: hir::HirId,
mut_access: bool) {
if cfg!(debug_assertions) {
if let Some(local_id_root) = local_id_root {
if hir_id.owner != local_id_root.index {
ty::tls::with(|tcx| {
let node_id = tcx.hir().hir_to_node_id(hir_id);
bug!("node {} with HirId::owner {:?} cannot be placed in \
TypeckTables with local_id_root {:?}",
tcx.hir().node_to_string(node_id),
DefId::local(hir_id.owner),
local_id_root)
});
}
} else {
// We use "Null Object" TypeckTables in some of the analysis passes.
// These are just expected to be empty and their `local_id_root` is
// `None`. Therefore we cannot verify whether a given `HirId` would
// be a valid key for the given table. Instead we make sure that
// nobody tries to write to such a Null Object table.
if mut_access {
bug!("access to invalid TypeckTables")
}
}
}
} Since some issues mention it happens with |
Minimal(to my ability) steps to reproduce this ICE:
config.toml (click me to expand)It's possible that only [llvm]
optimize = true
release-debuginfo = false
assertions = false
ccache = "/usr/bin/ccache"
static-libstdcpp = false
ninja = true
targets = "X86"
experimental-targets = ""
link-jobs = 4
[build]
build = "x86_64-unknown-linux-gnu"
host = ["x86_64-unknown-linux-gnu"]
target = ["x86_64-unknown-linux-gnu"]
docs = true
compiler-docs = false
submodules = true
fast-submodules = true
locked-deps = false
full-bootstrap = false
extended = false
tools = [ "src" ]
verbose = 0
sanitizers = false
profiler = false
low-priority = true
local-rebuild = false
print-step-timings = false
[install]
[rust]
optimize = true
debug = false
codegen-units = 1
codegen-units-std = 1
debug-assertions = true #required!
debuginfo = false
debuginfo-lines = false
debuginfo-only-std = false
debuginfo-tools = false
backtrace = true
incremental = true
experimental-parallel-queries = true
channel = "dev"
rpath = true
verbose-tests = false
optimize-tests = false
debuginfo-tests = false
codegen-tests = false
ignore-git = false
lld = false
deny-warnings = true
backtrace-on-ice = true
[target.x86_64-unknown-linux-gnu]
[dist]
src-tarball = false
missing-tools = false
4. apply this minimal clippy patch (click me to expand)ie. diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs
index 35c00fb6..4a5972f8 100644
--- a/clippy_lints/src/lib.rs
+++ b/clippy_lints/src/lib.rs
@@ -180,6 +180,7 @@ pub mod precedence;
pub mod ptr;
pub mod ptr_offset_with_cast;
pub mod question_mark;
+pub mod random_state;
pub mod ranges;
pub mod redundant_clone;
pub mod redundant_field_names;
@@ -486,6 +487,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
reg.register_late_lint_pass(box ptr_offset_with_cast::Pass);
reg.register_late_lint_pass(box redundant_clone::RedundantClone);
reg.register_late_lint_pass(box slow_vector_initialization::Pass);
+ reg.register_late_lint_pass(box random_state::Pass);
reg.register_late_lint_pass(box types::RefToMut);
reg.register_lint_group("clippy::restriction", Some("clippy_restriction"), vec![
@@ -1028,6 +1030,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
fallible_impl_from::FALLIBLE_IMPL_FROM,
mutex_atomic::MUTEX_INTEGER,
needless_borrow::NEEDLESS_BORROW,
+ random_state::RANDOM_STATE,
redundant_clone::REDUNDANT_CLONE,
unwrap::PANICKING_UNWRAP,
unwrap::UNNECESSARY_UNWRAP,
diff --git a/clippy_lints/src/random_state.rs b/clippy_lints/src/random_state.rs
new file mode 100644
index 00000000..d75ffd47
--- /dev/null
+++ b/clippy_lints/src/random_state.rs
@@ -0,0 +1,25 @@
+use rustc::hir::Ty;
+use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
+use rustc::{declare_tool_lint, lint_array};
+
+declare_clippy_lint! {
+ pub RANDOM_STATE,
+ nursery,
+ "use of RandomState"
+}
+
+pub struct Pass;
+
+impl LintPass for Pass {
+ fn get_lints(&self) -> LintArray {
+ lint_array!(RANDOM_STATE)
+ }
+}
+
+impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
+ fn check_ty(&mut self, cx: &LateContext<'a, 'tcx>, ty: &Ty) {
+ if let Some(_tys) = cx.tables.node_id_to_type_opt(ty.hir_id) { // ICE will be here
+ }
+ }
+}
+
looks like this(click me to expand)[package]
name = "dummy3"
version = "0.1.0"
authors = ["blah <blah@blah.blah>"]
edition = "2018"
[dependencies]
thread_local = "= 0.3.6"
What you'll see is approximately this (click me to expand):/tmp/dummy4
$ RUST_BACKTRACE=1 /tmp/rust-clippy/target/debug/cargo-clippy
!! LD_LIBRARY_PATH=/home/xftroxgpx/build/2nonpkgs/rust.stuff/rust/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib:/home/xftroxgpx/build/2nonpkgs/rust.stuff/rust/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib:/home/xftroxgpx/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib:/home/xftroxgpx/build/2nonpkgs/rust.stuff/rust/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib:/home/xftroxgpx/build/2nonpkgs/rust.stuff/rust/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib:/home/xftroxgpx/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib:
!! Executing '/home/xftroxgpx/build/2nonpkgs/rust.stuff/cargo/cargo//target/release//cargo' in pwd='/tmp/dummy4' with args: 'check'
Updating crates.io index
glibc64:../sysdeps/posix/getaddrinfo.c:2212/getaddrinfo: cargo[22956](full:'/home/xftroxgpx/build/2nonpkgs/rust.stuff/cargo/cargo//target/release//cargo') for user xftroxgpx(1000(eff:xftroxgpx(1000))) 1of2 attempting to resolve (requested)hostname:
api.github.com
glibc64:../sysdeps/posix/getaddrinfo.c:2212/getaddrinfo: !! REENTRANT_NAME == 'gethostbyname2_r' hostname='api.github.com'
cargo: cargo[22956](full:'/home/xftroxgpx/build/2nonpkgs/rust.stuff/cargo/cargo//target/release//cargo') for user xftroxgpx(1000(eff:xftroxgpx(1000))) 2of2 successfully resolved requested hostname('api.github.com') which was not transformed('api.github.com') as follows:
192.30.253.117 api.github.com
glibc64:../sysdeps/posix/getaddrinfo.c:2212/getaddrinfo: cargo[22956](full:'/home/xftroxgpx/build/2nonpkgs/rust.stuff/cargo/cargo//target/release//cargo') for user xftroxgpx(1000(eff:xftroxgpx(1000))) 1of2 attempting to resolve (requested)hostname:
github.com
glibc64:../sysdeps/posix/getaddrinfo.c:2212/getaddrinfo: !! REENTRANT_NAME == 'gethostbyname2_r' hostname='github.com'
cargo: cargo[22956](full:'/home/xftroxgpx/build/2nonpkgs/rust.stuff/cargo/cargo//target/release//cargo') for user xftroxgpx(1000(eff:xftroxgpx(1000))) 2of2 successfully resolved requested hostname('github.com') which was not transformed('github.com') as follows:
140.82.118.3 github.com
glibc64:../sysdeps/posix/getaddrinfo.c:2212/getaddrinfo: cargo[22956](full:'/home/xftroxgpx/build/2nonpkgs/rust.stuff/cargo/cargo//target/release//cargo') for user xftroxgpx(1000(eff:xftroxgpx(1000))) 1of2 attempting to resolve (requested)hostname:
github.com
glibc64:../sysdeps/posix/getaddrinfo.c:2212/getaddrinfo: !! REENTRANT_NAME == 'gethostbyname2_r' hostname='github.com'
cargo: cargo[22956](full:'/home/xftroxgpx/build/2nonpkgs/rust.stuff/cargo/cargo//target/release//cargo') for user xftroxgpx(1000(eff:xftroxgpx(1000))) 2of2 successfully resolved requested hostname('github.com') which was not transformed('github.com') as follows:
140.82.118.3 github.com
Checking lazy_static v1.2.0
Checking thread_local v0.3.6
error: internal compiler error: src/librustc/ty/context.rs:246: node type $crate::lazy::Lazy<Mutex<ThreadIdManager>> (id=2800) with HirId::owner DefId(0/0:134 ~ thread_local[ca19]::thread_id[0]::{{impl}}[3]::deref[0]::__stability[0]::LAZY[0]) cannot be placed in TypeckTables with local_id_root DefId(0/0:131 ~ thread_local[ca19]::thread_id[0]::{{impl}}[3]::deref[0]::__stability[0])
thread '<unnamed>' panicked at 'Box<Any>', src/librustc_errors/lib.rs:588:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
1: std::sys_common::backtrace::print
2: std::panicking::default_hook::{{closure}}
3: std::panicking::default_hook
4: rustc::util::common::panic_hook
5: std::panicking::rust_panic_with_hook
6: std::panicking::begin_panic
7: rustc_errors::Handler::bug
8: rustc::util::bug::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::util::bug::opt_span_bug_fmt
13: rustc::util::bug::bug_fmt
14: rustc::ty::context::validate_hir_id_for_typeck_tables::{{closure}}
15: rustc::ty::context::tls::with::{{closure}}
16: rustc::ty::context::tls::with_context::{{closure}}
17: rustc::ty::context::tls::with_context_opt
18: rustc::ty::context::tls::with_context
19: rustc::ty::context::tls::with
20: rustc::ty::context::TypeckTables::node_id_to_type_opt
21: <clippy_lints::random_state::Pass as rustc::lint::LateLintPass<'a, 'tcx>>::check_ty
at /tmp/rust-clippy/clippy_lints/src/random_state.rs:21
22: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_ty
23: rustc::hir::intravisit::walk_item
24: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::lint::context::LintContext<'tcx>>::with_lint_attrs
25: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
26: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_decl
27: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_stmt
28: rustc::hir::intravisit::walk_block
29: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_block
30: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::lint::context::LintContext<'tcx>>::with_lint_attrs
31: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
32: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_body
33: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_nested_body
34: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_fn
35: rustc::hir::intravisit::walk_item
36: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::lint::context::LintContext<'tcx>>::with_lint_attrs
37: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
38: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_decl
39: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_stmt
40: rustc::hir::intravisit::walk_block
41: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_block
42: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::lint::context::LintContext<'tcx>>::with_lint_attrs
43: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
44: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_body
45: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_nested_body
46: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_fn
47: rustc::hir::intravisit::walk_impl_item
48: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::lint::context::LintContext<'tcx>>::with_lint_attrs
49: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_impl_item
50: rustc::hir::intravisit::walk_impl_item_ref
51: rustc::hir::intravisit::walk_item
52: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::lint::context::LintContext<'tcx>>::with_lint_attrs
53: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
54: rustc::hir::intravisit::walk_mod
55: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
56: rustc::hir::intravisit::walk_item
57: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::lint::context::LintContext<'tcx>>::with_lint_attrs
58: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
59: rustc::hir::intravisit::walk_mod
60: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
61: rustc::hir::intravisit::walk_crate
62: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::lint::context::LintContext<'tcx>>::with_lint_attrs
63: rustc::lint::context::check_crate
64: rustc::util::common::time
65: rustc_rayon_core::tlv::with
66: <std::thread::local::LocalKey<T>>::with
67: rustc::ty::context::tls::enter_global
68: rustc::ty::context::TyCtxt::create_and_enter
69: rustc_driver::driver::phase_3_run_analysis_passes
70: rustc_driver::driver::compile_input
71: rustc_driver::run_compiler_with_pool
72: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
73: std::panicking::try::do_call
74: __rust_maybe_catch_panic
75: std::panicking::try
76: std::panic::catch_unwind
77: rustc_rayon_core::unwind::halt_unwinding
78: <rustc_rayon_core::job::StackJob<L, F, R> as rustc_rayon_core::job::Job>::execute
79: rustc_rayon_core::registry::WorkerThread::wait_until_cold
80: rustc_rayon_core::registry::main_loop::{{closure}}
81: <scoped_tls::ScopedKey<T>>::set
82: <std::thread::local::LocalKey<T>>::with
83: <scoped_tls::ScopedKey<T>>::set
84: rustc_rayon_core::thread_pool::ThreadPool::scoped_pool::{{closure}}
85: __rust_maybe_catch_panic
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.33.0-dev (664c7797f 2019-01-09) 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 `thread_local`.
To learn more, run the command again with --verbose.
|
Performance shouldn't be impacted (see [1] for a perf run) and this should allow us to catch more bugs, e.g. [2] and [3]. [1]: rust-lang#64262 [2]: rust-lang#64250 [3]: rust-lang#57298
Performance shouldn't be impacted (see [1] for a perf run) and this should allow us to catch more bugs, e.g. [2] and [3]. [1]: rust-lang#64262 [2]: rust-lang#64250 [3]: rust-lang#57298
This should be fixed by #64250 |
EDIT3: ignore everything(to save time) and skip directly to this comment for this ICE reproduction steps.
EDIT2:
this is probably already fixednope! To reproduce the ICE currently, you have to do this because rust-clippy worked around it.EDIT: ICE only happens when
rustc
has been compiled withdebug-assertions = true
After successfully compiling
rust-clippy
HEAD with thisrustc
HEAD, runningrust-clippy
on itself causes an ICE like so:Meta
I used this
config.toml
when I compiledrustc
.I'm on ArchLinux x86_64.
Maybe it's something I did, and it's not
rustc
's or evenclippy
's fault.The text was updated successfully, but these errors were encountered: