Skip to content

hitting unreachable code when opening files #5640

Closed
@Emilgardis

Description

@Emilgardis

OS: Windows 10.
rustc: nightly-x86_64-pc-windows-gnu rustc 1.47.0-nightly (a7eff7913 2020-07-28)

I get repeating unreachable panics when I open a file. This seems to repeat for a while and then suddenly stops.
I have debug info set to 1, verbose output and experimental set to false

I've edited https://github.com/rust-analyzer/rust-analyzer/blob/5af32aeb2b83c7ae8adf3e088bf4f3691aa45eb1/crates/ra_proc_macro_srv/src/proc_macro/bridge/rpc.rs#L105

to link

    t => unreachable!("could not decode with type {}: got {:?} - tags={:?}", stringify!($name), t, stringify!(
        match u8::decode(r, s) {
            $(tag::$variant => {
                $(let $field = DecodeMut::decode(r, s);)*
                $name::$variant $(($field))*
            })*
        }
    )),

Steps to reproduce:

  • With VSC open rust-analyzer/rust-analyzer local repo, without any files in editor.
  • Browse to crates\rust-analyzer\src\bin\main.rs and open an editor tab.
  • It's possible from here to also just restart ra and the panic will trigger again

The following panic repeatedly hits.

thread 'main' panicked at 'internal error: entered unreachable code: could not decode with type TokenStreamBuilder: got 7 - tags="match u8 :: decode(r, s)\n{\n    tag :: drop => { TokenStreamBuilder :: drop } tag :: new =>\n    { TokenStreamBuilder :: new } tag :: push =>\n    { TokenStreamBuilder :: push } tag :: build =>\n    { TokenStreamBuilder :: build }\n}"', crates\ra_proc_macro_srv\src\proc_macro\bridge\mod.rs:252:5
stack backtrace:
   0: backtrace::backtrace::dbghelp::trace
             at C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\backtrace-0.3.46\src\backtrace/dbghelp.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\backtrace-0.3.46\src\backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at library\std\src\sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at library\std\src\sys_common/backtrace.rs:59
   4: core::fmt::write
             at library\core\src\fmt/mod.rs:1117
   5: std::io::Write::write_fmt
             at library\std\src\io/mod.rs:1510
   6: std::sys_common::backtrace::_print
             at library\std\src\sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at library\std\src\sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at library\std\src/panicking.rs:198
   9: std::panicking::default_hook
             at library\std\src/panicking.rs:217
  10: std::panicking::rust_panic_with_hook
             at library\std\src/panicking.rs:526
  11: rust_begin_unwind
             at library\std\src/panicking.rs:437
  12: std::panicking::begin_panic_fmt
             at library\std\src/panicking.rs:391
  13: <ra_proc_macro_srv::proc_macro::bridge::api_tags::Method as ra_proc_macro_srv::proc_macro::bridge::rpc::DecodeMut<S>>::decode
             at crates\ra_proc_macro_srv\src\proc_macro\bridge/rpc.rs:0
  14: <ra_proc_macro_srv::proc_macro::bridge::server::Dispatcher<ra_proc_macro_srv::proc_macro::bridge::server::MarkedTypes<S>> as ra_proc_macro_srv::proc_macro::bridge::server::DispatcherTrait>::dispatch
             at crates\ra_proc_macro_srv\src\proc_macro\bridge/server.rs:102
  15: <ra_proc_macro_srv::proc_macro::bridge::server::SameThread as ra_proc_macro_srv::proc_macro::bridge::server::ExecutionStrategy>::run_bridge_and_client::{{closure}}
             at crates\ra_proc_macro_srv\src\proc_macro\bridge/server.rs:152
  16: <ra_proc_macro_srv::proc_macro::bridge::closure::Closure<A,R> as core::convert::From<&mut F>>::from::call
             at crates\ra_proc_macro_srv\src\proc_macro\bridge/closure.rs:20
  17: units_search
  18: units_search
  19: units_search
  20: units_search
  21: units_search
  22: units_search
  23: units_search
  24: units_search
  25: units_search
  26: units_search
  27: units_search
  28: units_search
  29: units_search
  30: units_search
  31: units_search
  32: units_search
  33: units_search
  34: units_search
  35: units_search
  36: units_search
  37: units_search
  38: units_search
  39: units_search
  40: units_search
  41: units_search
  42: units_search
  43: units_search
  44: <ra_proc_macro_srv::proc_macro::bridge::server::SameThread as ra_proc_macro_srv::proc_macro::bridge::server::ExecutionStrategy>::run_bridge_and_client
             at crates\ra_proc_macro_srv\src\proc_macro\bridge/server.rs:154
  45: ra_proc_macro_srv::proc_macro::bridge::server::run_server
             at crates\ra_proc_macro_srv\src\proc_macro\bridge/server.rs:276
  46: ra_proc_macro_srv::proc_macro::bridge::server::<impl ra_proc_macro_srv::proc_macro::bridge::client::Client<fn(ra_proc_macro_srv::proc_macro::bridge::client::TokenStream) .> ra_proc_macro_srv::proc_macro::bridge::client::TokenStream>>::run
             at crates\ra_proc_macro_srv\src\proc_macro\bridge/server.rs:289
  47: ra_proc_macro_srv::dylib::Expander::expand
             at crates\ra_proc_macro_srv\src/dylib.rs:146
  48: ra_proc_macro_srv::ProcMacroSrv::expand
             at crates\ra_proc_macro_srv\src/lib.rs:39
  49: ra_proc_macro_srv::cli::run
             at crates\ra_proc_macro_srv\src/cli.rs:14
  50: rust_analyzer::main
             at crates\rust-analyzer\src/bin/main.rs:31
  51: std::rt::lang_start::{{closure}}
             at C:\Users\Emil\.rustup\toolchains\nightly-x86_64-pc-windows-gnu\lib/rustlib/src/rust\library\std\src/rt.rs:67
  52: std::rt::lang_start_internal::{{closure}}
             at library\std\src/rt.rs:52
  53: std::panicking::try::do_call
             at library\std\src/panicking.rs:348
  54: std::panicking::try
             at library\std\src/panicking.rs:325
  55: std::panic::catch_unwind
             at library\std\src/panic.rs:394
  56: std::rt::lang_start_internal
             at library\std\src/rt.rs:51
  57: main
  58: __tmainCRTStartup
             at D:/mingwbuild/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:337
  59: mainCRTStartup
             at D:/mingwbuild/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:221
  60: units_search
  61: units_search
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

So, seems like something is expecting to get dispatch TokenStreamBuilder with a decode of 7.

INFO [8/1/2020, 11:44:49 AM]: Extension version: 0.4.0-dev
INFO [8/1/2020, 11:44:49 AM]: Using configuration {
  lruCapacity: 30,
  files: { watcher: 'client', exclude: [] },
  notifications: { cargoTomlNotFound: true },
  cargo: {
    autoreload: true,
    noDefaultFeatures: false,
    allFeatures: false,
    features: [],
    loadOutDirsFromCheck: true,
    target: null
  },
  rustfmt: { extraArgs: [], overrideCommand: null },
  checkOnSave: {
    enable: true,
    extraArgs: [],
    command: 'clippy',
    overrideCommand: null,
    allTargets: false,
    noDefaultFeatures: null,
    allFeatures: null,
    features: null
  },
  cargoRunner: null,
  runnableEnv: null,
  inlayHints: {
    enable: true,
    typeHints: true,
    chainingHints: false,
    parameterHints: true,
    maxLength: 20
  },
  completion: {
    addCallParenthesis: true,
    addCallArgumentSnippets: true,
    postfix: { enable: true }
  },
  callInfo: { full: true },
  updates: { channel: 'nightly', askBeforeDownload: true },
  serverPath: 'C:/Users/Emil/.cargo/bin/rust-analyzer.exe',
  trace: { server: 'verbose', extension: true },
  procMacro: { enable: true },
  debug: {
    engine: 'auto',
    sourceFileMap: {
      '/rustc/<id>': '${env:USERPROFILE}/.rustup/toolchains/<toolchain-id>/lib/rustlib/src/rust'
    },
    openDebugPane: false,
    engineSettings: {}
  },
  lens: { enable: true, run: true, debug: true, implementations: true },
  hoverActions: {
    enable: true,
    implementations: true,
    run: true,
    debug: true,
    gotoTypeDef: true
  },
  linkedProjects: null,
  withSysroot: true,
  diagnostics: {
    enable: true,
    enableExperimental: false,
    warningsAsInfo: [],
    warningsAsHint: []
  }
}
INFO [8/1/2020, 11:44:49 AM]: PersistentState: {
  lastCheck: 1592251425728,
  releaseId: 27538406,
  serverVersion: '0.3.187-nightly'
}
INFO [8/1/2020, 11:44:49 AM]: Using server binary at C:/Users/Emil/.cargo/bin/rust-analyzer.exe
DEBUG [8/1/2020, 11:44:49 AM]: Checking availability of a binary at C:/Users/Emil/.cargo/bin/rust-analyzer.exe
DEBUG [8/1/2020, 11:44:49 AM]: C:/Users/Emil/.cargo/bin/rust-analyzer.exe --version: {
  status: 0,
  signal: null,
  output: [ null, 'rust-analyzer 5af32ae\n', '' ],
  pid: 1580,
  stdout: 'rust-analyzer 5af32ae\n',
  stderr: ''
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions