Skip to content
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

SIGABRT ICE in proc macro #100257

Closed
K4rakara opened this issue Aug 8, 2022 · 6 comments
Closed

SIGABRT ICE in proc macro #100257

K4rakara opened this issue Aug 8, 2022 · 6 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@K4rakara
Copy link

K4rakara commented Aug 8, 2022

This is a really weird one... and it might be a bit of a mess to debug. I honestly wish I could tell you more, but this is beyond my knowledge of the compiler.

Code

This requires multiple crates, due to it being a proc macro issue. Here is the smallest reproducible case I was able to create.

Meta

rustc --version --verbose:

rustc 1.65.0-nightly (d394408fb 2022-08-07)
binary: rustc
commit-hash: d394408fb38c4de61f765a3ed5189d2731a1da91
commit-date: 2022-08-07
host: x86_64-unknown-linux-gnu
release: 1.65.0-nightly
LLVM version: 14.0.6

Error output

   Compiling big_mac v0.1.0 (/tmp/repo/macro)
   Compiling lib v0.1.0 (/tmp/repo/lib)
fatal runtime error: failed to initiate panic, error 5
error: could not compile `lib`

Caused by:
  process didn't exit successfully: `rustc --crate-name lib --edition=2021 lib/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=a2786eed45a16c47 -C extra-filename=-a2786eed45a16c47 --out-dir /tmp/repo/target/debug/deps -C incremental=/tmp/repo/target/debug/incremental -L dependency=/tmp/repo/target/debug/deps --extern big_mac=/tmp/repo/target/debug/deps/libbig_mac-47b147c1d91db7e1.so` (signal: 6, SIGABRT: process abort signal)

There is no backtrace, since it failed to initiate a panic, and therefore failed to initiate a stack unwind.

@K4rakara K4rakara added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 8, 2022
@K4rakara
Copy link
Author

K4rakara commented Aug 8, 2022

Worth noting: this happens both on nightly and on stable.

@luqmana
Copy link
Member

luqmana commented Aug 8, 2022

I believe this is a dupe of #63804. Sticking proc_macro types in TLS is not supported (which is what memoize! is doing in your repro).

@K4rakara
Copy link
Author

K4rakara commented Aug 8, 2022

This isn't holding the generated token streams outside the lifetime of the macro invocation though, so shouldn't it be fine?

@luqmana
Copy link
Member

luqmana commented Aug 8, 2022

The MEMO thread local generated in each function memoize! is applied to (just generics_and_tuples in this case) will stick around until it is cleaned up at thread destruction. What's happening here is it seems that that cleanup occurs after the proc macro server disconnects and so when the proc_macro types in your thread local go to notify the server to clean up the corresponding data, it hits this panic:

panic!("procedural macro API is used outside of a procedural macro");

As for why the error is so opaque (failed to initiate panic) that's a separate bug with TLS dtors + panics: #24479

@bjorn3
Copy link
Member

bjorn3 commented Aug 9, 2022

Should this issue be closed as not a bug?

@K4rakara
Copy link
Author

K4rakara commented Aug 9, 2022

I think it should be closed as duplicate, but its up to you.

@bjorn3 bjorn3 closed this as completed Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants