Skip to content

proc macro server crashing due to corrupted proc_macro::bridge::client::ProcMacro::Bang name #12489

@MoSal

Description

@MoSal
rustc 1.63.0-nightly (5435ed691 2022-06-07)
rust-analyzer 66a842124b52cb005e9dee4605df161badb295e0

Patch to see what's going on

 crates/proc-macro-srv/src/abis/abi_1_58/mod.rs | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/crates/proc-macro-srv/src/abis/abi_1_58/mod.rs b/crates/proc-macro-srv/src/abis/abi_1_58/mod.rs
index dd3fd8b64..39d588657 100644
--- a/crates/proc-macro-srv/src/abis/abi_1_58/mod.rs
+++ b/crates/proc-macro-srv/src/abis/abi_1_58/mod.rs
@@ -86,6 +86,7 @@ impl Abi {
     }
 
     pub fn list_macros(&self) -> Vec<(String, ProcMacroKind)> {
+        eprintln!("exported_macros len={}", self.exported_macros.len());
         self.exported_macros
             .iter()
             .map(|proc_macro| match proc_macro {
@@ -93,6 +94,10 @@ impl Abi {
                     (trait_name.to_string(), ProcMacroKind::CustomDerive)
                 }
                 proc_macro::bridge::client::ProcMacro::Bang { name, .. } => {
+                    if name.len() > 1024 {
+                        eprintln!("mapping Bang name_len={}", name.len());
+                        eprintln!("mapping Bang name_start={:#?}", &name.as_bytes()[0..1024]);
+                    }
                     (name.to_string(), ProcMacroKind::FuncLike)
                 }
                 proc_macro::bridge::client::ProcMacro::Attr { name, .. } => {

What's going on

exported_macros len=4
mapping Bang name_len=140612842588360
mapping Bang name_start=[
[ERROR rust_analyzer::reload] proc macro server crashed: server exited

This is a serious regression in nightly and it's important to fix it before the next release.
@matklad, please take a look.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions