Rust-GCC / Rust-GCC/gccrs

segfault in `Rust::Compile::HIRCompileBase::coercion_site1`, static slices

Open
#3,970 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
static foo: [usize; 3] = [1, 2, 3];

static slice_1: &'static [usize] = &slice_2;
static slice_2: &'static [usize] = &foo;

original:

//@ build-pass
#![allow(dead_code)]
#![allow(dead_code)]


static foo: [usize; 3] = [1, 2, 3];

static slice_1: &'static [usize] = &slice_2;
static slice_2: &'static [usize] = &foo;

fn main() {}

Version information:

5dc8c4d20d62462ebce137c6e5146235ab9e9e2e

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

Program output

crab1: error: the value of ‘mvce::slice_2’ is not usable in a constant expression
crab1: internal compiler error: Segmentation fault
0x2fecaf8 internal_error(char const*, ...)
	../../gcc/diagnostic-global-context.cc:517
0x196d57f crash_signal
	../../gcc/toplev.cc:321
0xdbf8ad Rust::Compile::HIRCompileBase::coercion_site1(tree_node*, Rust::TyTy::BaseType*, Rust::TyTy::BaseType*, unsigned long, unsigned long)
	../../gcc/rust/backend/rust-compile.cc:86
0xdbfc78 Rust::Compile::HIRCompileBase::coercion_site1(tree_node*, Rust::TyTy::BaseType*, Rust::TyTy::BaseType*, unsigned long, unsigned long)
	../../gcc/rust/backend/rust-compile.cc:77
0xdbfc78 Rust::Compile::HIRCompileBase::coercion_site(unsigned int, tree_node*, Rust::TyTy::BaseType*, Rust::TyTy::BaseType*, unsigned long, unsigned long)
	../../gcc/rust/backend/rust-compile.cc:69
0x118eac2 Rust::Compile::HIRCompileBase::compile_constant_item(unsigned int, Rust::TyTy::BaseType*, Rust::TyTy::BaseType*, Rust::Resolver::CanonicalPath const&, Rust::HIR::Expr&, unsigned long, unsigned long)
	../../gcc/rust/backend/rust-compile-base.cc:891
0x115782c Rust::Compile::CompileItem::visit(Rust::HIR::StaticItem&)
	../../gcc/rust/backend/rust-compile-item.cc:61
0xdbeeeb Rust::Compile::CompileItem::compile(Rust::HIR::Item*, Rust::Compile::Context*, Rust::TyTy::BaseType*, unsigned long)
	../../gcc/rust/backend/rust-compile-item.h:37
0xdbeeeb Rust::Compile::CompileCrate::go()
	../../gcc/rust/backend/rust-compile.cc:48
0xdbeeeb Rust::Compile::CompileCrate::Compile(Rust::HIR::Crate&, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile.cc:41
0xdb9970 Rust::Session::compile_crate(char const*)
	../../gcc/rust/rust-session-manager.cc:732
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 reproducer and the backtrace entry point in gcc/rust/backend/rust-compile.cc, especially HIRCompileBase::coercion_site1. Run the provided crab1 command to reproduce the failure; done means the static-slice case no longer causes a segmentation fault or internal compiler error.

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
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.