segfault in expand_decl_macro with empty feature gate inside macor
Open
Nobody has claimed this yet.
bug
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 19h 55m
- Merged PRs (30d)
- 67
Description
auto-reduced (treereduce-rust):
//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use
macro_rules! make_macro {
($macro_name:ident $($matcher:tt)*) => {
#[feature]
macro_rules! $macro_name {
(<= =>) => {};
}
};
}
make_macro!(interpolations type $($i:ident)::* + $e:expr);
interpolations!(<= type foo::bar + x.sort() =>);
original:
//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use
macro_rules! make_macro {
($macro_name:ident $($matcher:tt)*) => {
#[feature]
macro_rules! $macro_name {
(<= =>) => {};
}
};
}
make_macro!(interpolations type $($i:ident)::* + $e:expr);
interpolations!(<= type foo::bar + x.sort() =>);
Version information:
5dc8c4d20d62462ebce137c6e5146235ab9e9e2e
Command:
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use
Program output
/tmp/icemaker_global_tempdir.AGJ5RW194Exn/rustc_testrunner_tmpdir_reporting.0pZVUqrltOVl/mvce.rs:3:11: error: macro not found
3 | #[feature]
| ^~~~~~~
crab1: internal compiler error: Segmentation fault
0x2fecaf8 internal_error(char const*, ...)
../../gcc/diagnostic-global-context.cc:517
0x196d57f crash_signal
../../gcc/toplev.cc:321
0xdddcc0 Rust::MacroExpander::expand_decl_macro(unsigned long, Rust::AST::MacroInvocData&, Rust::AST::MacroRulesDefinition&, Rust::AST::InvocKind)
../../gcc/rust/expand/rust-macro-expand.cc:43
0xddedf5 Rust::MacroExpander::expand_invoc(Rust::AST::MacroInvocation&, Rust::AST::InvocKind)
../../gcc/rust/expand/rust-macro-expand.cc:309
0xea014c void Rust::ExpandVisitor::expand_macro_children<std::vector<std::unique_ptr<Rust::AST::Item, std::default_delete<Rust::AST::Item> >, std::allocator<std::unique_ptr<Rust::AST::Item, std::default_delete<Rust::AST::Item> > > >, std::unique_ptr<Rust::AST::Item, std::default_delete<Rust::AST::Item> > >(std::vector<std::unique_ptr<Rust::AST::Item, std::default_delete<Rust::AST::Item> >, std::allocator<std::unique_ptr<Rust::AST::Item, std::default_delete<Rust::AST::Item> > > >&, std::function<std::unique_ptr<Rust::AST::Item, std::default_delete<Rust::AST::Item> > (Rust::AST::SingleASTNode)>)
../../gcc/rust/expand/rust-expand-visitor.h:131
0xea014c Rust::ExpandVisitor::expand_inner_items(std::vector<std::unique_ptr<Rust::AST::Item, std::default_delete<Rust::AST::Item> >, std::allocator<std::unique_ptr<Rust::AST::Item, std::default_delete<Rust::AST::Item> > > >&)
../../gcc/rust/expand/rust-expand-visitor.cc:239
0xda39b3 Rust::Session::expansion(Rust::AST::Crate&, Rust::Resolver2_0::NameResolutionContext&)
../../gcc/rust/rust-session-manager.cc:958
0xdb8ed7 Rust::Session::compile_crate(char const*)
../../gcc/rust/rust-session-manager.cc:620
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the crash with the reduced /tmp/im/2/a.rs input and the listed compiler flag, then start at gcc/rust/expand/rust-macro-expand.cc:43 using the provided backtrace. Trace the empty feature-gate macro expansion and verify that the compiler reports the error without a segmentation fault.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100