Skip to content

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

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
MoSal opened this issue Jun 8, 2022 · 7 comments · Fixed by #12492
Closed
Labels
A-proc-macro proc macro

Comments

@MoSal
Copy link

MoSal commented Jun 8, 2022

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.

@lnicola lnicola added the A-proc-macro proc macro label Jun 8, 2022
@bjorn3
Copy link
Member

bjorn3 commented Jun 8, 2022

This is a serious regression in nightly and it's important to fix it before the next release.

This is caused by a change in rustc and not in rust-analyzer. There have been several changes in the proc macro abi last week: https://github.com/rust-lang/rust/commits/master/library/proc_macro Note that nightly rustc is not guaranteed to have working proc macros with rust-analyzer. Instead we handle it on a best-effort case for nightly. The proc macro abi is not stable and just an implementation detail of rustc. For this reason we have a copy of the proc macro server for every rustc version with a different proc macro abi.

@alexjg would you mind updating for the latest proc macro changes?

@MoSal
Copy link
Author

MoSal commented Jun 8, 2022

@bjorn3 Thanks for the explanation.

The text you quoted comes from the issue template.

@bjorn3
Copy link
Member

bjorn3 commented Jun 8, 2022

The text you quoted comes from the issue template.

I see. My bad.

@lnicola
Copy link
Member

lnicola commented Jun 8, 2022

TBF, it's from the regression issue template 😄.

@alexjg
Copy link
Contributor

alexjg commented Jun 8, 2022

I'm on holiday this week but should be able to sort this next week unless someone else gets there first

@bjorn3
Copy link
Member

bjorn3 commented Jun 8, 2022

I'm going to give it a try then. Enjoy your holiday!

@bjorn3
Copy link
Member

bjorn3 commented Jun 8, 2022

Opened #12492

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

Successfully merging a pull request may close this issue.

5 participants