segfault with macro and function that does not exist ?
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
#[collapse_debuginfo(no)]
macro_rules! outer {
() => {
one();
};
}
fn main() {
let ret = outer!();
}
original:
//@ ignore-lldb
// Test that macro attribute #[collapse_debuginfo(no)]
// overrides "collapse_macro_debuginfo=external" flag
//@ compile-flags:-g -C collapse_macro_debuginfo=external
// === GDB TESTS ===================================================================================
// gdb-command:run
// gdb-command:next
// gdb-command:frame
// gdb-check:[...]#one_callsite[...]
// gdb-command:next
// gdb-command:frame
// gdb-command:continue
fn one() {
std::process::exit(ret);
}
#[collapse_debuginfo(no)]
macro_rules! outer {
() => {
one(); // #one_callsite
};
}
fn main() {
let ret = //@ compile-flags:-g -C collapse_macro_debuginfo=external; // #break
outer!();
std::process::exit(ret);
}
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.dXnmbxBLFUkA/rustc_testrunner_tmpdir_reporting.2pJCxgMbLFUD/mvce.rs:1:3: error: macro not found
1 | #[collapse_debuginfo(no)]
| ^~~~~~~~~~~~~~~~~~
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
0xe9b560 Rust::ExpandVisitor::maybe_expand_expr(std::unique_ptr<Rust::AST::Expr, std::default_delete<Rust::AST::Expr> >&)
../../gcc/rust/expand/rust-expand-visitor.cc:339
0xea10db void Rust::ExpandVisitor::expand_macro_children<std::vector<std::unique_ptr<Rust::AST::Stmt, std::default_delete<Rust::AST::Stmt> >, std::allocator<std::unique_ptr<Rust::AST::Stmt, std::default_delete<Rust::AST::Stmt> > > >, std::unique_ptr<Rust::AST::Stmt, std::default_delete<Rust::AST::Stmt> > >(std::vector<std::unique_ptr<Rust::AST::Stmt, std::default_delete<Rust::AST::Stmt> >, std::allocator<std::unique_ptr<Rust::AST::Stmt, std::default_delete<Rust::AST::Stmt> > > >&, std::function<std::unique_ptr<Rust::AST::Stmt, std::default_delete<Rust::AST::Stmt> > (Rust::AST::SingleASTNode)>)
../../gcc/rust/expand/rust-expand-visitor.h:131
0xea10db Rust::ExpandVisitor::expand_inner_stmts(Rust::AST::BlockExpr&)
../../gcc/rust/expand/rust-expand-visitor.cc:330
0xea2290 Rust::ExpandVisitor::visit(Rust::AST::BlockExpr&)
../../gcc/rust/expand/rust-expand-visitor.cc:630
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 Rust snippet and the listed compiler command. Start at gcc/rust/expand/rust-macro-expand.cc:43, then trace the callers shown in the backtrace. Done means the invalid macro and missing function produce diagnostics without an internal compiler error or segmentation fault.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100