Rust-GCC / Rust-GCC/gccrs

ICE: Segmentation fault

Open
#4,473 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

Code
#[repr(i32)]
enum Foo {}
trait NewTrait {}
impl NewTrait for Foo {}

Meta

1a91028

Error output
bug.rs:9:1: error: unsupported representation for zero-variant enum
    9 | enum Foo {}
      | ^~~~
bug.rs:9:1: error: unsupported representation for zero-variant enum
Backtrace

crab1: internal compiler error: Segmentation fault
0x2c1ef7b internal_error(char const*, ...)
      ../../gcc/diagnostic-global-context.cc:787
0x161f903 crash_signal
      ../../gcc/toplev.cc:325
0x7fc0c20f408f ???
      /build/glibc-B3wQXB/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0xe5d180 Rust::TyTy::BaseType::get_kind() const
      ../../gcc/rust/typecheck/rust-tyty.cc:263
0xe5d180 bool Rust::TyTy::BaseType::is<Rust::TyTy::ParamType const>() const
      ../../gcc/rust/typecheck/rust-tyty.h:306
0xe5d180 Rust::TyTy::ParamType const* Rust::TyTy::BaseType::try_as<Rust::TyTy::ParamType const>() const
      ../../gcc/rust/typecheck/rust-tyty.h:333
0xe5d180 Rust::TyTy::BaseType::destructure() const
      ../../gcc/rust/typecheck/rust-tyty.cc:529
0xe5d83c Rust::TyTy::BaseType::needs_generic_substitutions() const
      ../../gcc/rust/typecheck/rust-tyty.cc:960
0xe9b845 Rust::Resolver::TypeCheckType::resolve_root_path(Rust::HIR::TypePath&, unsigned long*, bool*)
      ../../gcc/rust/typecheck/rust-hir-type-check-type.cc:467
0xe9d133 Rust::Resolver::TypeCheckType::visit(Rust::HIR::TypePath&)
      ../../gcc/rust/typecheck/rust-hir-type-check-type.cc:147
0xe9aac8 Rust::Resolver::TypeCheckType::Resolve(Rust::HIR::Type&)
      ../../gcc/rust/typecheck/rust-hir-type-check-type.cc:71
0xe712f0 Rust::TyTy::SubstitutionRef::get_mappings_from_generic_args(Rust::HIR::GenericArgs&, std::vector<Rust::TyTy::Region, std::allocator<Rust::TyTy::Region> > const&)
      ../../gcc/rust/typecheck/rust-tyty-subst.cc:752
0xe84d27 Rust::TyTy::TypeBoundPredicate::apply_generic_arguments(Rust::HIR::GenericArgs*, bool, bool)
      ../../gcc/rust/typecheck/rust-tyty-bounds.cc:544
0xe86050 Rust::Resolver::TypeCheckBase::get_predicate_from_bound(Rust::HIR::TypePath&, tl::optional<std::reference_wrapper<Rust::HIR::Type> >, Rust::BoundPolarity, bool, bool)
      ../../gcc/rust/typecheck/rust-tyty-bounds.cc:342
0xe91ef8 Rust::Resolver::TypeCheckItem::resolve_impl_block_substitutions(Rust::HIR::ImplBlock&, bool&)
      ../../gcc/rust/typecheck/rust-hir-type-check-item.cc:740
0xe9895a Rust::Resolver::TypeCheckItem::visit(Rust::HIR::ImplBlock&)
      ../../gcc/rust/typecheck/rust-hir-type-check-item.cc:484
0xe9190d Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
      ../../gcc/rust/typecheck/rust-hir-type-check-item.cc:57
0xe9190d Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
      ../../gcc/rust/typecheck/rust-hir-type-check-item.cc:43
0xe4c12b Rust::Resolver::TypeResolution::Resolve(Rust::HIR::Crate&)
      ../../gcc/rust/typecheck/rust-hir-type-check.cc:71
0xd11bcf Rust::Session::compile_crate(char const*)
      ../../gcc/rust/rust-session-manager.cc:763
../gccrs/build/gcc/crab1 bug.rs -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

Reproduce the crash with bug.rs using the reported gccrs command and then trace the listed type-checking path, starting at rust/typecheck/rust-tyty.cc and rust-hir-type-check-type.cc. Compare the handling of the zero-variant enum and its trait implementation; done means this input reports the unsupported representation without an internal compiler 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
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.