-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-proc-macrosArea: Procedural macrosArea: Procedural macrosA-thread-localsArea: Thread local storage (TLS)Area: Thread local storage (TLS)E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
ICE will be produced on any channel.
Error:
thread 'rustc' panicked at 'use-after-free in `proc_macro` handle', src/libcore/option.rs:1190:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.39.0-beta.1 (968967007 2019-09-24) running on x86_64-apple-darwin
note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin
note: some of the compiler flags provided by cargo are hidden
error: custom attribute panicked
--> proc_macro_bug/src/main.rs:7:1
|
7 | #[some_macro(0)]
| ^^^^^^^^^^^^^^^^
|
= help: message: use-after-free in `proc_macro` handle
error: aborting due to previous error
error: could not compile `proc_macro_bug`.
LocalKey
used in macro generation:
extern crate proc_macro;
extern crate quote;
extern crate syn;
use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_quote, Path};
thread_local! {
static DEFAULT_CRATE_PATH: Path = parse_quote! { ::std };
}
#[proc_macro_attribute]
pub fn some_macro(_: TokenStream, _: TokenStream) -> TokenStream {
TokenStream::from(DEFAULT_CRATE_PATH.with(|default_crate_path| {
quote! {
use #default_crate_path::boxed::Box;
}
}))
}
Macro calls (should be 2 at least) which produce error:
#[some_macro(0)]
struct Abc {}
#[some_macro(0)]
struct Cde {}
fn main() {}
Repo with minimal code sample: https://github.com/olegnn/proc-macro-ICE.
nathan, peter-lyons-kehl and ple1n
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-proc-macrosArea: Procedural macrosArea: Procedural macrosA-thread-localsArea: Thread local storage (TLS)Area: Thread local storage (TLS)E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.