Rust-GCC / Rust-GCC/gccrs

segfault clone_type_no_bounds_impl()

Open
#4,478 0 comments 0 reactions 0 assignees View on GitHub

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

fn id<'c, 'b>(c: &'b &'x dyn Fn(&&dyn Fn(&'c))) -> &'c &'b dyn  Fn() {
    &f
}

original:

#![feature(no_core)]
#![no_core]
// run-pass
#![allow(unused_variables)]
fn Y() {
    let f: &dyn Fn(&&'b dyn Fn(&&'b dyn  Fn(&&dyn Fn(&&dyn Fn(&&'b dyn Fn(&&'b dyn Fn(dyn Fn(&&'b dyn Fn(&&'b dyn Fn(&i32)))))))))) = unused_variables&|x| &|x| {}(&i33);
    {
    let f: &dyn Fn(&&'b dyn Fn(&&'b dyn  Fn(&&dyn Fn(&&dyn Fn(&&'b dyn Fn(&&'b dyn Fn(dyn Fn(&&'b dyn Fn(&&'b dyn Fn(&i32)))))))))) = Y&|x| &|x| {}(&i33);
    {};
};
}

fn id<'c, 'b>(c: &'b &'x dyn Fn(&&dyn Fn(&'c))) -> &'c &'b dyn  Fn(&&dyn Fn(&&dyn Fn(f: &'b &'Fn(&&dyn Fn(&&dyn Fn(f: &'b &'b dyn Fn(&&dyn Fn(&&'b dyn Fn(&&'b dyn Fn(&&'b dyn Fn(&i32)))))))) dyn Fn(&&'b dyn  Fn(&&dyn Fn(&&dyn Fn(f: &'b &'b dyn Fn(&&dyn Fn(&&'b dyn Fn(&&'b dyn Fn(&&'b dyn Fn(&i32)))))))))))) {
    &f
}

Version information:

1a9102843099b18f9dbb6b5e979436f6c4566f1c

Command:
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use

Program output

crab1: internal compiler error: Segmentation fault
0x3097ef9 internal_error(char const*, ...)
	../../gcc/diagnostic-global-context.cc:787
0x19c085f crash_signal
	../../gcc/toplev.cc:325
0xde1769 Rust::AST::TypeNoBounds::clone_type_no_bounds() const
	../../gcc/rust/ast/rust-ast.h:1529
0xde1769 Rust::AST::ReferenceType::ReferenceType(Rust::AST::ReferenceType const&)
	../../gcc/rust/ast/rust-type.h:646
0xde1769 Rust::AST::ReferenceType::clone_type_no_bounds_impl() const
	../../gcc/rust/ast/rust-type.h:698
0xdedd91 Rust::AST::Type::clone_type() const
	../../gcc/rust/ast/rust-ast.h:1484
0xdedd91 Rust::AST::TypePathFunction::TypePathFunction(Rust::AST::TypePathFunction const&)
	../../gcc/rust/ast/rust-path.h:1135
0xdedd91 Rust::AST::TypePathSegmentFunction::TypePathSegmentFunction(Rust::AST::TypePathSegmentFunction const&)
	../../gcc/rust/ast/rust-path.h:1203
0xdedd91 Rust::AST::TypePathSegmentFunction::clone_type_path_segment_impl() const
	../../gcc/rust/ast/rust-path.h:1244
0xcea6cc Rust::AST::TypePathSegment::clone_type_path_segment() const
	../../gcc/rust/ast/rust-path.h:867
0xcea6cc Rust::AST::TypePath::TypePath(Rust::AST::TypePath const&)
	../../gcc/rust/ast/rust-path.h:1317
0xcea6cc Rust::AST::TraitBound::TraitBound(Rust::AST::TraitBound const&)
	../../gcc/rust/ast/rust-type.h:81
0xd7af1c Rust::Parser<Rust::Lexer>::parse_type_no_bounds()
	../../gcc/rust/parse/rust-parse-impl.hxx:6711
0xd7bfa7 Rust::Parser<Rust::Lexer>::parse_reference_type_inner(unsigned long)
	../../gcc/rust/parse/rust-parse-impl.hxx:6333
0xd7c9ba Rust::Parser<Rust::Lexer>::parse_reference_type()
	../../gcc/rust/parse/rust-parse-impl.hxx:6360
0xd7afff Rust::Parser<Rust::Lexer>::parse_type_no_bounds()
	../../gcc/rust/parse/rust-parse-impl.hxx:6526
0xd7bfa7 Rust::Parser<Rust::Lexer>::parse_reference_type_inner(unsigned long)
	../../gcc/rust/parse/rust-parse-impl.hxx:6333
0xd7c9ba Rust::Parser<Rust::Lexer>::parse_reference_type()
	../../gcc/rust/parse/rust-parse-impl.hxx:6360
0xd7d19f Rust::Parser<Rust::Lexer>::parse_type(bool)
	../../gcc/rust/parse/rust-parse-impl.hxx:5652
0xd906c3 Rust::Parser<Rust::Lexer>::parse_function_param()
	../../gcc/rust/parse/rust-parse-impl.hxx:2399
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 /tmp/icemaker_global_tempdir.OypEAej2sZax/rustc_testrunner_tmpdir_reporting.XVGSGMxM5rH9/mvce.rs -o/tmp/icemaker_global_tempdir.OypEAej2sZax/rustc_testrunner_tmpdir_reporting.XVGSGMxM5rH9/binaryname -frust-incomplete-and-experimental-compiler-do-not-use
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reduced Rust input and the reported clone_type_no_bounds_impl() stack, then read the clone implementations in rust-ast.h and rust-type.h alongside the parser paths in rust-parse-impl.hxx and rust-path.h. Run crab1 with the issue's compiler flag and reduced input; done means the input no longer segfaults and a regression case covers the failure.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.