Rust-GCC / Rust-GCC/gccrs

ICE: NR2: segfault with edition 2018

Open
#4,618 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-edition=2018 -frust-incomplete-and-experimental-compiler-do-not-use
mod a {

    use ::*;
}

original:

// { dg-additional-options "-frust-edition=2015" }

#![feature(no_core)]
#![no_core]

mod a {
    #[allow(unused)]
    use ::*;
}

Version information:

696cb485cfa9969c952d6765889d82ed548ca15c

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

Program output

crab1: error: failed to locate crate ‘core’
crab1: error: failed to locate crate ‘std’
crab1: error: unknown crate ‘core’
crab1: error: unknown crate ‘std’
crab1: internal compiler error: Segmentation fault
0x32c0107 internal_error(char const*, ...)
	../../gcc/diagnostic-global-context.cc:787
0x1a7e17f crash_signal
	../../gcc/toplev.cc:325
0x10026f8 Rust::Resolver2_0::Early::build_import_mapping(std::pair<unsigned int, std::vector<Rust::Resolver2_0::TopLevel::ImportKind, std::allocator<Rust::Resolver2_0::TopLevel::ImportKind> > >&&)
	../../gcc/rust/resolve/rust-early-name-resolver-2.0.cc:228
0x10029fa Rust::Resolver2_0::Early::visit(Rust::AST::UseDeclaration&)
	../../gcc/rust/resolve/rust-early-name-resolver-2.0.cc:584
0xe81450 void Rust::AST::DefaultASTVisitor::visit<Rust::AST::Item>(std::unique_ptr<Rust::AST::Item, std::default_delete<Rust::AST::Item> >&)
	../../gcc/rust/ast/rust-ast-visitor.h:421
0xe81450 Rust::AST::DefaultASTVisitor::visit(Rust::AST::Module&)
	../../gcc/rust/ast/rust-ast-visitor.cc:843
0xfee181 operator()
	../../gcc/rust/resolve/rust-default-resolver.cc:66
0xfee181 scope_inner<Rust::Resolver2_0::CanonicalPathCtx::scope<Rust::Resolver2_0::DefaultResolver::visit(Rust::AST::Module&)::<lambda()> >(Rust::NodeId, std::string, Rust::Resolver2_0::DefaultResolver::visit(Rust::AST::Module&)::<lambda()>&&)::<lambda()>, Rust::Resolver2_0::DefaultResolver::visit(Rust::AST::Module&)::<lambda()> >
	../../gcc/rust/resolve/rust-name-resolution-context.h:456
0xfee181 scope<Rust::Resolver2_0::DefaultResolver::visit(Rust::AST::Module&)::<lambda()> >
	../../gcc/rust/resolve/rust-name-resolution-context.h:399
0xfee181 scope<Rust::Resolver2_0::DefaultResolver::visit(Rust::AST::Module&)::<lambda()> >
	../../gcc/rust/resolve/rust-name-resolution-context.h:392
0xfee181 operator()
	../../gcc/rust/resolve/rust-default-resolver.cc:69
0xfee181 __invoke_impl<void, Rust::Resolver2_0::DefaultResolver::visit(Rust::AST::Module&)::<lambda()>&>
	/usr/include/c++/16.1.1/bits/invoke.h:63
0xfee181 __invoke_r<void, Rust::Resolver2_0::DefaultResolver::visit(Rust::AST::Module&)::<lambda()>&>
	/usr/include/c++/16.1.1/bits/invoke.h:113
0xfee181 _M_invoke
	/usr/include/c++/16.1.1/bits/std_function.h:295
0xfe4120 std::function<void ()>::operator()() const
	/usr/include/c++/16.1.1/bits/std_function.h:581
0xfe4120 Rust::Resolver2_0::NameResolutionContext::scoped(Rust::Resolver2_0::Rib::Kind, unsigned int, std::function<void ()>, tl::optional<Rust::Identifier>)
	../../gcc/rust/resolve/rust-name-resolution-context.cc:341
0xfeb405 Rust::Resolver2_0::DefaultResolver::visit(Rust::AST::Module&)
	../../gcc/rust/resolve/rust-default-resolver.cc:73
0xffe82c Rust::Resolver2_0::Early::visit(Rust::AST::Module&)
	../../gcc/rust/resolve/rust-early-name-resolver-2.0.cc:308
0xe7f21f void Rust::AST::DefaultASTVisitor::visit<Rust::AST::Item>(std::unique_ptr<Rust::AST::Item, std::default_delete<Rust::AST::Item> >&)
	../../gcc/rust/ast/rust-ast-visitor.h:421
0xe7f21f Rust::AST::DefaultASTVisitor::visit(Rust::AST::Crate&)
	../../gcc/rust/ast/rust-ast-visitor.cc:39
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 /tmp/icemaker_global_tempdir.Y6DWmzQt0PsB/rustc_testrunner_tmpdir_reporting.5kTXHAOMcrfb/mvce.rs -o/tmp/icemaker_global_tempdir.Y6DWmzQt0PsB/rustc_testrunner_tmpdir_reporting.5kTXHAOMcrfb/binaryname -frust-edition=2018 -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 by running the reduced Rust reproducer with -frust-edition=2018 and the incomplete compiler flag. Inspect build_import_mapping in gcc/rust/resolve/rust-early-name-resolver-2.0.cc at line 228, where the backtrace reports the crash. Done means the reproducer no longer segfaults and reports the invalid import or missing crate without an 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
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.