Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Compiler panics on latest RLS when compiling crates that depend on bitflags 1.0.5 #1449

Closed
Ten0 opened this issue May 2, 2019 · 18 comments · Fixed by rust-lang/rust#60649
Closed

Comments

@Ten0
Copy link

Ten0 commented May 2, 2019

I'm trying to develop a crate which ends up using nix as a dependency.
I'm getting the following error through RLS since I've updated to the latest stable:
(stable-x86_64-unknown-linux-gnu unchanged - rustc 1.34.1 (fc50f328b 2019-04-24), ArchLinux 5.0.10-arch1-1-ARCH)

Could not compile `nix`.
process didn't exit successfully: `/home/xxx/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rls --crate-name nix /home/xxx/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/nix-0.13.0/src/lib.rs --color never --crate-type lib --emit=dep-info,metadata -C debuginfo=2 -C metadata=e41c62fd44c3a368 -C extra-filename=-e41c62fd44c3a368 --out-dir /home/xxx/bug/target/rls/debug/deps -L dependency=/home/xxx/bug/target/rls/debug/deps --extern bitflags=/home/xxx/bug/target/rls/debug/deps/libbitflags-162b4a56bd08b901.rmeta --extern cfg_if=/home/xxx/bug/target/rls/debug/deps/libcfg_if-dab04317bb5fc6db.rmeta --extern libc=/home/xxx/bug/target/rls/debug/deps/liblibc-98ec97d48b6e5b85.rmeta --extern void=/home/xxx/bug/target/rls/debug/deps/libvoid-e59ad8b8a3ae09b4.rmeta --cap-lints allow --error-format=json --sysroot /home/xxx/.rustup/toolchains/stable-x86_64-unknown-linux-gnu` (exit code: 101)

Using "rust-client.logToFile": true, to get the log, I get this additional information:

{"message":"src/librustc/ty/context.rs:541: node_type: no type for node `expr <Self>::AT_SYMLINK_NOFOLLOW (id=43804)`","code":null,"level":"error: internal compiler error","spans":[],"children":[],"rendered":"error: internal compiler error: src/librustc/ty/context.rs:541: node_type: no type for node `expr <Self>::AT_SYMLINK_NOFOLLOW (id=43804)`\n\n"}
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:620:9
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}

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.34.1 (fc50f328b 2019-04-24) 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

I'm unsure whether this is an RLS or Rust bug, but this error does not happen when compiling through cargo check, cargo build, cargo build --release, cargo doc, etc, only through RLS, and I may not be able to give proper information in a rustc issue as to what the precise flags that cause this are.

The following minimal project triggers the bug when opening VSCode with the RLS extension installed :

Cargo.toml:

[package]
name = "bug"
version = "1.0.0"
authors = ["Le me"]
edition = "2018"
publish = false

[dependencies]
nix = "0.13.0"

src/main.rs:

fn main() {
	let hw = "HelloWorld";
	println!("{}", hw);
}
@Ten0
Copy link
Author

Ten0 commented May 2, 2019

I haven't diagnosed which crate triggers another of these, but I'm also getting an error when compiling diesel:

{"message":"src/librustc/ty/context.rs:530: node_id_to_type: no type for node `expr <Self>::EMPTY (id=130531)`","code":null,"level":"error: internal compiler error","spans":[],"children":[],"rendered":"error: internal compiler error: src/librustc/ty/context.rs:530: node_id_to_type: no type for node `expr <Self>::EMPTY (id=130531)`\n\n"}
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:588:9
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}

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 (2aa4c46cf 2019-02-28) 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

I tried downgrading to an older Rust release (1.33.0) and it did not fix this issue.

@Bravo555
Copy link

Bravo555 commented May 2, 2019

Same thing with sdl2 crate:

Could not compile `sdl2`.
process didn't exit successfully: `/home/marcel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rls --crate-name sdl2 /home/marcel/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/sdl2-0.32.2/src/sdl2/lib.rs --color never --crate-type lib --emit=dep-info,metadata -C debuginfo=2 --cfg 'feature="default"' -C metadata=036db9bf7cdd3c9c -C extra-filename=-036db9bf7cdd3c9c --out-dir /home/marcel/Documents/dev/learning/opengl/nercury.github.io/opengl-tutorial/target/rls/debug/deps -L dependency=/home/marcel/Documents/dev/learning/opengl/nercury.github.io/opengl-tutorial/target/rls/debug/deps --extern bitflags=/home/marcel/Documents/dev/learning/opengl/nercury.github.io/opengl-tutorial/target/rls/debug/deps/libbitflags-162b4a56bd08b901.rmeta --extern lazy_static=/home/marcel/Documents/dev/learning/opengl/nercury.github.io/opengl-tutorial/target/rls/debug/deps/liblazy_static-3d9653f4293d1765.rmeta --extern libc=/home/marcel/Documents/dev/learning/opengl/nercury.github.io/opengl-tutorial/target/rls/debug/deps/liblibc-9c5393a63b000927.rmeta --extern num=/home/marcel/Documents/dev/learning/opengl/nercury.github.io/opengl-tutorial/target/rls/debug/deps/libnum-f1550afe3806bc12.rmeta --extern rand=/home/marcel/Documents/dev/learning/opengl/nercury.github.io/opengl-tutorial/target/rls/debug/deps/librand-f6b5a9079df2ff7d.rmeta --extern sdl2_sys=/home/marcel/Documents/dev/learning/opengl/nercury.github.io/opengl-tutorial/target/rls/debug/deps/libsdl2_sys-04f1bc3577a75b57.rmeta --cap-lints allow --error-format=json --sysroot /home/marcel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu` (exit code: 101)
{"message":"src/librustc/ty/context.rs:541: node_type: no type for node `expr <Self>::NOMOD (id=73197)`","code":null,"level":"error: internal compiler error","spans":[],"children":[],"rendered":"error: internal compiler error: src/librustc/ty/context.rs:541: node_type: no type for node `expr <Self>::NOMOD (id=73197)`\n\n"}
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:620:9
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}

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.34.1 (fc50f328b 2019-04-24) 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

@m10s
Copy link

m10s commented May 2, 2019

Same with png:

Could not compile `png`.
process didn't exit successfully: `/Users/Michael/.rustup/toolchains/stable-x86_64-apple-darwin/bin/rls --crate-name png /Users/Michael/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/png-0.14.1/src/lib.rs --color never --crate-type lib --emit=dep-info,metadata -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="deflate"' --cfg 'feature="png-encoding"' -C metadata=9db8ebc124f361d0 -C extra-filename=-9db8ebc124f361d0 --out-dir /Users/Michael/rust/foo/target/rls/debug/deps -L dependency=/Users/Michael/rust/foo/target/rls/debug/deps --extern bitflags=/Users/Michael/rust/foo/target/rls/debug/deps/libbitflags-34e85485b1ddcbd8.rmeta --extern deflate=/Users/Michael/rust/foo/target/rls/debug/deps/libdeflate-5104fa98d76c741b.rmeta --extern inflate=/Users/Michael/rust/foo/target/rls/debug/deps/libinflate-b4eaa1b16660e524.rmeta --extern num_iter=/Users/Michael/rust/foo/target/rls/debug/deps/libnum_iter-a1893e0ace8cb9d6.rmeta --cap-lints allow --error-format=json --sysroot /Users/Michael/.rustup/toolchains/stable-x86_64-apple-darwin` (exit code: 101)
{"message":"src/librustc/ty/context.rs:541: node_type: no type for node `expr <Self>::IDENTITY (id=18857)`","code":null,"level":"error: internal compiler error","spans":[],"children":[],"rendered":"error: internal compiler error: src/librustc/ty/context.rs:541: node_type: no type for node `expr <Self>::IDENTITY (id=18857)`\n\n"}
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:620:9
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}

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.34.1 (fc50f328b 2019-04-24) running on x86_64-apple-darwin

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

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

@ghost
Copy link

ghost commented May 3, 2019

I also noticed the same issue when trying to use the clap crate. It compiles just fine by running $ cargo build, etc., but have an error when using RLS extension in VSCode.

{"message":"src/librustc/ty/context.rs:541: node_type: no type for node `expr <Self>::SC_NEGATE_REQS (id=50338)`","code":null,"level":"error: internal compiler error","spans":[],"children":[],"rendered":"error: internal compiler error: src/librustc/ty/context.rs:541: node_type: no type for node `expr <Self>::SC_NEGATE_REQS (id=50338)`\n\n"}
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:620:9
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}

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.34.1 (fc50f328b 2019-04-24) running on x86_64-apple-darwin

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

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

@m10s
Copy link

m10s commented May 3, 2019

I checked the common dependencies of all affected crates. It seems that the bitflags 1.0.5 update has caused this issue. Locking bitflags to 1.0.4 fixes the problem for me.

@ghost
Copy link

ghost commented May 3, 2019

That seems to have worked for me too.

@alexheretic
Copy link
Member

Nice one guys cargo update -p 'bitflags:1.0.5' --precise 1.0.4 is a effective workaround.

Now we need to figure out why rls can't handle this dependency when cargo can.

@Ten0 Ten0 changed the title Compiler panics on latest RLS when compiling nix crate Compiler panics on latest RLS when compiling crates that depend on bitflags 1.0.5 May 3, 2019
@norru
Copy link

norru commented May 3, 2019

Now we need to figure out why rls can't handle this dependency when cargo can.

It'd be interesting to see what the changes between 1.0.4 and 1.0.5 are. Semver says "minor".

@norru
Copy link

norru commented May 3, 2019

1.0.5
@KodrAus KodrAus released this a day ago
Use compiletest_rs flags supported by stable toolchain (bitflags/bitflags#171)
Put the user provided attributes first (bitflags/bitflags#173)
Make bitflags methods const on newer compilers (bitflags/bitflags#175)

@norru
Copy link

norru commented May 3, 2019

Copying my stacktrace from #1450 for convenience:

rls --cli

{"message":"src/librustc/ty/context.rs:556: node_type: no type for node `expr <Self>::IS_REGULAR (id=76215)`","code":null,"level":"error: internal compiler error","spans":[],"children":[],"rendered":"error: internal compiler error: src/librustc/ty/context.rs:556: node_type: no type for node `expr <Self>::IS_REGULAR (id=76215)`\n\n"}
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:636:9
stack backtrace:

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.36.0-nightly (00859e3e6 2019-04-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

   0:     0x7f40d9af4e13 - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::h0d6c439dca72ca11
                               at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1:     0x7f40d9aecc9b - std::sys_common::backtrace::_print::hea4ea4af6c4411e1
                               at src/libstd/sys_common/backtrace.rs:71
   2:     0x7f40d9af1076 - std::panicking::default_hook::{{closure}}::hb59690c480567b51
                               at src/libstd/sys_common/backtrace.rs:59
                               at src/libstd/panicking.rs:197
   3:     0x7f40d9af0e09 - std::panicking::default_hook::h0b2c7c1f5ffd3b4c
                               at src/libstd/panicking.rs:211
   4:     0x7f40db57eef0 - rustc::util::common::panic_hook::h843db43ad0cf1382
   5:     0x7f40d9af1868 - std::panicking::rust_panic_with_hook::h711d147cd5e0cf06
                               at src/libstd/panicking.rs:478
   6:     0x7f40da42400c - std::panicking::begin_panic::ha898008710af638b
   7:     0x7f40da43ec8e - rustc_errors::Handler::bug::hf3a8200efe6143d1
   8:     0x7f40db2cdc42 - rustc::util::bug::opt_span_bug_fmt::{{closure}}::hc32a43ddbab80360
   9:     0x7f40db2ccb69 - rustc::ty::context::tls::with_opt::{{closure}}::hdd224f249b19b8fd
  10:     0x7f40db2cca84 - rustc::ty::context::tls::with_context_opt::h3832967f752274c7
  11:     0x7f40db2ccb16 - rustc::ty::context::tls::with_opt::ha1b5a581a82ea24b
  12:     0x7f40db2cdb57 - rustc::util::bug::opt_span_bug_fmt::h593e16e90d210bd5
  13:     0x7f40db2cdac1 - rustc::util::bug::bug_fmt::hb4707b36bd10e7f8
  14:     0x7f40db8b088a - rustc::ty::context::TypeckTables::node_type::{{closure}}::h3b11e279de4ea90e
  15:     0x7f40db8b102a - rustc::ty::context::TypeckTables::expr_ty_adjusted::h32a1e626407aaad5
  16:     0x7f40dc6d7ca5 - rustc_save_analysis::SaveContext::get_expr_data::h78c7ab51d332aff3
  17:     0x7f40dc6c1208 - <rustc_save_analysis::dump_visitor::DumpVisitor<O> as syntax::visit::Visitor>::visit_expr::haba26a253446d0cd
  18:     0x7f40dc6a8751 - rustc_save_analysis::dump_visitor::DumpVisitor<O>::process_assoc_const::h522c23606f1706fc
  19:     0x7f40dc6b1cca - <rustc_save_analysis::dump_visitor::DumpVisitor<O> as syntax::visit::Visitor>::visit_item::h4b3a5450c224ada3
  20:     0x7f40dc6a5efc - rustc_save_analysis::dump_visitor::DumpVisitor<O>::process_method::h5b0729d6a1d55eff
  21:     0x7f40dc6b1dd2 - <rustc_save_analysis::dump_visitor::DumpVisitor<O> as syntax::visit::Visitor>::visit_item::h4b3a5450c224ada3
  22:     0x7f40dc6b454b - <rustc_save_analysis::dump_visitor::DumpVisitor<O> as syntax::visit::Visitor>::visit_item::h4b3a5450c224ada3
  23:     0x7f40dc6b454b - <rustc_save_analysis::dump_visitor::DumpVisitor<O> as syntax::visit::Visitor>::visit_item::h4b3a5450c224ada3
  24:     0x7f40dc6b158b - <rustc_save_analysis::dump_visitor::DumpVisitor<O> as syntax::visit::Visitor>::visit_mod::h6daa1cf87e6c0394
  25:     0x7f40dc6da830 - <rustc_save_analysis::DumpHandler as rustc_save_analysis::SaveHandler>::save::hd40bf9919f17d6d1
  26:     0x7f40dd65368c - rustc::dep_graph::graph::DepGraph::with_ignore::ha94958a6e9181ec7
  27:     0x7f40dd6493f5 - rustc_driver::run_compiler::{{closure}}::{{closure}}::{{closure}}::hd9b442400b8375ac
  28:     0x7f40dd6484a3 - rustc::util::common::time::h5e41458033525ee7
  29:     0x7f40dd631aee - rustc::ty::context::tls::enter_global::h9821e6759f9d2f3a
  30:     0x7f40dd649572 - rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}::h3271e54ef7e41e4b
  31:     0x7f40dd2b8f44 - rustc_interface::passes::create_global_ctxt::{{closure}}::h1b5279f309d64952
  32:     0x7f40dd64b81a - rustc_interface::interface::run_compiler_in_existing_thread_pool::hcca8ecaeda3badf1
  33:     0x7f40dd6ca5a3 - std::thread::local::LocalKey<T>::with::ha08aa88e11205f04
  34:     0x7f40dd690874 - scoped_tls::ScopedKey<T>::set::h3906ac5daec2139d
  35:     0x7f40dd6c610f - syntax::with_globals::h3460b90a71271dc2
  36:     0x7f40dd624129 - std::sys_common::backtrace::__rust_begin_short_backtrace::h93f92d975520f5fe
  37:     0x7f40d9b02639 - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:85
  38:     0x7f40dd63e718 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h7c9983fddd413bcc
  39:     0x7f40d9ad377e - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::hf5407189cfbe0e45
                               at /rustc/00859e3e653973120006aaf3227823062dde1ba7/src/liballoc/boxed.rs:704
  40:     0x7f40d9b012af - std::sys::unix::thread::Thread::new::thread_start::h367a735064fa0a3b
                               at /rustc/00859e3e653973120006aaf3227823062dde1ba7/src/liballoc/boxed.rs:704
                               at src/libstd/sys_common/thread.rs:13
                               at src/libstd/sys/unix/thread.rs:79
  41:     0x7f40d94646da - start_thread
  42:     0x7f40d8f7588e - __clone
  43:                0x0 - <unknown>
query stack during panic:
end of query stack
{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}

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.36.0-nightly (00859e3e6 2019-04-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

garlond added a commit to garlond/talan that referenced this issue May 3, 2019
@KodrAus
Copy link

KodrAus commented May 3, 2019

Oh dear... I’d forgotten we had an RLS issue caused by the changes in bitflags to support const functions before publishing it.

The author pointed out the crash initially.

Pinning bitflags to 1.0.4 would be your best bet until we’ve got this sorted.

@SLMT
Copy link

SLMT commented May 4, 2019

Same issue here while compiling clap. Pinning bitflags to 1.0.4 works for me, too.

@RamiHg
Copy link

RamiHg commented May 4, 2019

I got the issue when using shrinkwraprs as a dependency. None of its versions worked. I had to actually strip it out.

@jonas-schievink
Copy link

@KodrAus consider yanking 1.0.5 until rust-lang/rust#59134 is fixed to reduce the impact of the bug - you can probably just republish it as 1.0.6 after this is sorted out

@KodrAus
Copy link

KodrAus commented May 7, 2019

@jonas-schievink Well, that bug was logged a few months ago and doesn't appear to have made any forward progress in that time. Do we know what a fix in RLS would look like?

Having RLS simply not work for such a pervasive dependency is unfortunate though, so I'll yank 1.0.5.

EDIT: Actually, that comment about not making forward progress is a bit unfair. It looks like you are exploring a fix.

@KodrAus
Copy link

KodrAus commented May 7, 2019

Alrighty, 1.0.5 has been yanked now so anybody pinned to 1.0.4 should be able to revert those tighter bounds. We won’t publish a new version that hits this bug.

@Xanewok
Copy link
Member

Xanewok commented May 8, 2019

Thanks everyone for investigating and posting a workaround! The fix for the current nightly is pending at rust-lang/rust#60649 (which hopefully will be backported to beta, in which case it will be available in Rust 1.35)

bors added a commit to rust-lang/rust that referenced this issue May 13, 2019
save-analysis: Fix ICE when processing associated constant

Closes #59134
Closes rust-lang/rls#1449

Thanks @swgillespie for helping tracking this down and fixing it!

r? @eddyb
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

11 participants