Skip to content

tracing::instrument causes rust-analyzer server to panic with "range end index out of range" #12740

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

Closed
tigercat2000 opened this issue Jul 11, 2022 · 2 comments

Comments

@tigercat2000
Copy link

rust-analyzer version: (eg. output of "Rust Analyzer: Show RA Version" command)
rust-analyzer version: 0.0.0 (5342f47 2022-07-09)

rustc version: (eg. output of rustc -V)
rustc 1.64.0-nightly (6dba4ed21 2022-07-09)

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTUP_HOME or CARGO_HOME)
tracing 0.1.35
tracing-attributes 0.1.22
proc-macro2 1.0.40

This may be related to this issue, but I'm not sure: #12674

Using the proc-macro tracing::instrument will cause rust-analyzer to panic.
This results in textDocument/hover and textDocument/inlayHint to return []. However, textDocument/publishDiagnostics still works.

Minimal reproduction:
Cargo.toml

[package]
name = "rabug"
version = "0.1.0"
edition = "2021"
[dependencies.tracing]
version = "0.1.35"
features = ["attributes"]

main.rs

#[tracing::instrument]
fn one() {
    let should_have_inlay = 1u32;
}

fn main() {
    println!("Hello, world!");
}

This causes the following panic:

thread '<unnamed>' panicked at 'range end index 4 out of range for slice of length 0', library\core\src\slice\index.rs:73:5
stack backtrace:
   0:     0x7ffd21e7339f - std::sys_common::backtrace::_print_fmt
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509/library\std\src\sys_common\backtrace.rs:66
   1:     0x7ffd21e7339f - std::sys_common::backtrace::_print::impl$0::fmt
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509/library\std\src\sys_common\backtrace.rs:45
   2:     0x7ffd21ea402a - core::fmt::write
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509/library\core\src\fmt\mod.rs:1198
   3:     0x7ffd21e65b8a - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509/library\std\src\io\mod.rs:1672
   4:     0x7ffd21e76d3b - std::sys_common::backtrace::_print
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509/library\std\src\sys_common\backtrace.rs:48
   5:     0x7ffd21e76d3b - std::sys_common::backtrace::print
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509/library\std\src\sys_common\backtrace.rs:35
   6:     0x7ffd21e76d3b - std::panicking::default_hook::closure$1
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509/library\std\src\panicking.rs:295
   7:     0x7ffd21e76967 - std::panicking::default_hook
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509/library\std\src\panicking.rs:314
   8:     0x7ffd21e7771c - std::panicking::rust_panic_with_hook
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509/library\std\src\panicking.rs:702
   9:     0x7ffd21e7749d - std::panicking::begin_panic_handler::closure$0
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509/library\std\src\panicking.rs:588
  10:     0x7ffd21e74087 - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509/library\std\src\sys_common\backtrace.rs:138
  11:     0x7ffd21e77170 - std::panicking::begin_panic_handler
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509/library\std\src\panicking.rs:584
  12:     0x7ffd21ec8715 - core::panicking::panic_fmt
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509/library\core\src\panicking.rs:142
  13:     0x7ffd21ea788b - core::slice::index::slice_end_index_len_fail_rt
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509/library\core\src\slice\index.rs:73
  14:     0x7ffd21e98079 - core::ops::function::FnOnce::call_once<never$ (*)(usize,usize),tuple$<usize,usize> >
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509/library\core\src\ops\function.rs:248
  15:     0x7ffd21e9ef09 - core::intrinsics::const_eval_select<tuple$<usize,usize>,never$ (*)(usize,usize),never$ (*)(usize,usize),never$>
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509/library\core\src\intrinsics.rs:2695
  16:     0x7ffd21ec88b9 - core::slice::index::slice_end_index_len_fail
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509/library\core\src\slice\index.rs:67
  17:     0x7ffd21df309e - core::slice::index::impl$3::index<u8>
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509\library\core\src\slice\index.rs:304
  18:     0x7ffd21bc70d1 - proc_macro::bridge::rpc::impl$26::decode<tuple$<> >
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509\library\proc_macro\src\bridge\rpc.rs:38
  19:     0x7ffd21bc9ea3 - proc_macro::bridge::rpc::impl$9::decode<tuple$<> >
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509\library\proc_macro\src\bridge\rpc.rs:169
  20:     0x7ffd21c0c153 - proc_macro::bridge::client::impl$79::decode<tuple$<> >
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509\library\proc_macro\src\bridge\client.rs:166
  21:     0x7ffd21bc1a1f - proc_macro::bridge::impl$81::decode<tuple$<>,proc_macro::bridge::client::Span>
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509\library\proc_macro\src\bridge\rpc.rs:57
  22:     0x7ffd21bc7293 - proc_macro::bridge::rpc::impl$11::decode<tuple$<>,proc_macro::bridge::ExpnGlobals<proc_macro::bridge::client::Span>,tuple$<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream> >
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509\library\proc_macro\src\bridge\rpc.rs:184
  23:     0x7ffd21c09cd4 - proc_macro::bridge::client::run_client::closure$0<tuple$<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream>,enum$<core::option::Option<proc_macro::bridge::client::TokenStream>, 1, 4294967295, Some>,proc_macro::bridge::client:
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509\library\proc_macro\src\bridge\client.rs:409
  24:     0x7ffd21bb0541 - core::panic::unwind_safe::impl$23::call_once<tuple$<>,proc_macro::bridge::client::run_client::closure_env$0<tuple$<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream>,enum$<core::option::Option<proc_macro::bridge::client::Toke
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509\library\core\src\panic\unwind_safe.rs:271
  25:     0x7ffd21bf9699 - std::panicking::try::do_call<core::panic::unwind_safe::AssertUnwindSafe<proc_macro::bridge::client::run_client::closure_env$0<tuple$<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream>,enum$<core::option::Option<proc_macro::br
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509\library\std\src\panicking.rs:492
  26:     0x7ffd21bfe9d3 - hashbrown::raw::alloc::inner::do_alloc::closure$1<alloc::alloc::Global>
  27:     0x7ffd21bf9575 - std::panicking::try<tuple$<>,core::panic::unwind_safe::AssertUnwindSafe<proc_macro::bridge::client::run_client::closure_env$0<tuple$<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream>,enum$<core::option::Option<proc_macro::br
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509\library\std\src\panicking.rs:456
  28:     0x7ffd21bf8fd1 - std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<proc_macro::bridge::client::run_client::closure_env$0<tuple$<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream>,enum$<core::option::Option<proc_macro::bridge
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509\library\std\src\panic.rs:137
  29:     0x7ffd21c09ab6 - proc_macro::bridge::client::run_client<tuple$<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream>,enum$<core::option::Option<proc_macro::bridge::client::TokenStream>, 1, 4294967295, Some>,proc_macro::bridge::client::impl$14::e
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509\library\proc_macro\src\bridge\client.rs:405
  30:     0x7ffd21c0a40f - proc_macro::bridge::client::impl$14::expand2::closure$0<proc_macro::TokenStream (*)(proc_macro::TokenStream,proc_macro::TokenStream)>
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509\library\proc_macro\src\bridge\client.rs:463
  31:     0x7ffd21ba30a7 - proc_macro::bridge::selfless_reify::reify_to_extern_c_fn_hrt_bridge::wrapper<proc_macro::bridge::buffer::Buffer,proc_macro::bridge::client::impl$14::expand2::closure_env$0<proc_macro::TokenStream (*)(proc_macro::TokenStream,proc_macro::TokenStream)> >
                               at /rustc/6dba4ed215e7a60f0a2a19c04f3f73691f89c509\library\proc_macro\src\bridge\selfless_reify.rs:64
  32:     0x7ff6d0bb27da - proc_macro_srv::abis::abi_1_63::proc_macro::bridge::server::run_server::h3a27ad728600f475
  33:     0x7ff6d0c1c164 - proc_macro_srv::abis::abi_1_63::Abi::expand::h3d39669a2061bfba
  34:     0x7ff6d0ba2463 - proc_macro_srv::abis::Abi::expand::hded60e9a536d5670
  35:     0x7ff6d0bca719 - proc_macro_srv::dylib::Expander::expand::h981f31f619b7e567
  36:     0x7ff6d0c1d8bf - proc_macro_srv::cli::run::h2e9c0af18802c7b1
  37:     0x7ff6d102bcd8 - std::sys_common::backtrace::__rust_begin_short_backtrace::h2dabe9515eb13df4
  38:     0x7ff6d1045265 - <T as serde::de::Expected>::fmt::h3d1d6f48318a66a7
  39:     0x7ff6d10accec - alloc::boxed::impl$44::call_once
                               at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\alloc\src\boxed.rs:1872
  40:     0x7ff6d10accec - alloc::boxed::impl$44::call_once
                               at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\library\alloc\src\boxed.rs:1872
  41:     0x7ff6d10accec - std::sys::windows::thread::impl$0::new::thread_start
                               at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src\sys\windows\thread.rs:56
  42:     0x7ffdfbb27034 - BaseThreadInitThunk
  43:     0x7ffdfd422651 - RtlUserThreadStart
@flodiebold
Copy link
Member

Duplicate of #12600, proc macro support is currently broken with nightly.

@flodiebold flodiebold closed this as not planned Won't fix, can't repro, duplicate, stale Jul 11, 2022
@tigercat2000
Copy link
Author

Ahhh, thank you for pointing me to the original issue 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants