NR2: ICE in get_traits_to_derive, at rust/ast/rust-ast.cc:297 with garbage derive
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 20h 2m
- Merged PRs (30d)
- 66
Description
auto-reduced (treereduce-rust):
//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use -frust-name-resolution-2.0
#[derive("{:?}", y)]
struct Port<T>(Port<()>);
original:
use std::thread;
use std::rc::Rc;
#[derive("{:?}", y)]
struct Port<T>(Port<()>);
fn main() {
#[derive("{:?}", y)]
struct Drop {
_x: Port<()>,
}
impl Drop for Foo {
fn thread(&mut self) {}
}
let x = foo(Port(Rc::spawn(())));
thread::spawn(move|| {
//~^ ERROR `Rc<()>` cannot be sent between threads safely
let x = foo(Port(Rc::new(())));
println!("{:?}", y)
});
}
Version information:
765121736dfe3f5b319bbe9837880deda326394e
Possibly related line of code:
https://github.com/Rust-GCC/gccrs/blob/765121736dfe3f5b319bbe9837880deda326394e/gcc/rust/ast/rust-ast.cc#L291-L303
Command:
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use -frust-name-resolution-2.0
Program output
crab1: internal compiler error: in get_traits_to_derive, at rust/ast/rust-ast.cc:297
0x861d8d Rust::AST::Attribute::get_traits_to_derive()
../../gcc/rust/ast/rust-ast.cc:297
0xd3d79a 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:185
0xc46135 Rust::Session::expansion(Rust::AST::Crate&, Rust::Resolver2_0::NameResolutionContext&)
../../gcc/rust/rust-session-manager.cc:959
0xc5bcd1 Rust::Session::compile_crate(char const*)
../../gcc/rust/rust-session-manager.cc:619
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 reduced input with -frust-incomplete-and-experimental-compiler-do-not-use and -frust-name-resolution-2.0, then read get_traits_to_derive in rust/ast/rust-ast.cc around line 297 and the expansion path in rust/expand/rust-expand-visitor.cc. Done means the input no longer triggers an internal compiler error and the regression is checked appropriately.
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
- 45/100