Rust-GCC / Rust-GCC/gccrs

segfault DefaultHIRVisitor, macros

Open
#4,187 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
20h 2m
Merged PRs (30d)
66

Description

auto-reduced (treereduce-rust):

//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use
macro x(
    $macro_name:ident,
    $macro2_name:ident,
    $type_name:ident,
    $field_name:ident,
    $const_name:ident
) {
    pub struct $type_name {}

    pub const $const_name: $type_name = $type_name {};

    #[x]
    macro_rules! $macro_name {
        () => {};
    }

    pub macro $type_name {
                (Copy $e:expr) => {},
                () => {;},

            }
}

x!(test_fields, test_fields2, x, field, MY_CONST);

pub fn check_fields_local() {
    test_fields!(check_fields);
}

original:

macro x(
    $macro_name:ident,
    $macro2_name:ident,
    $type_name:ident,
    $field_name:ident,
    $const_name:ident
) {
    pub struct $type_name {}

    pub const $const_name: $type_name = $type_name {};

    #[x]
    macro_rules! $macro_name {
        (check_fields) => {{
            assert_eq!($const_name.field, Field::MacroCtxt);
        }};
    }

    pub macro $type_name {
            (Copy $e:expr) => {},
            (check_fields) => {test_fields!(check_fields);},

        }
}

x!(test_fields, test_fields2, x, field, MY_CONST);

pub fn check_fields_local() {
    test_fields!(check_fields);
    test_fields2!(check_fields);
}

Version information:

5a762b9243e834d69f90985950f4ef330f16b34f

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

Program output

/tmp/icemaker_global_tempdir.CmTzlVK6SkSa/rustc_testrunner_tmpdir_reporting.EhADlG9zJYJK/mvce.rs:12:7: error: macro not found
   12 |     #[x]
      |       ^
crab1: internal compiler error: Segmentation fault
0x301f909 internal_error(char const*, ...)
	../../gcc/diagnostic-global-context.cc:786
0x199fb9f crash_signal
	../../gcc/toplev.cc:323
0x0 Rust::HIR::DefaultHIRVisitor::visit(Rust::HIR::TupleType&)
	../../gcc/rust/hir/tree/rust-hir-visitor.h:333
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 the reduced Rust source and the listed crab1 command, using the reported revision 5a762b9243e834d69f90985950f4ef330f16b34f. Start at Rust::HIR::DefaultHIRVisitor::visit(Rust::HIR::TupleType&) in gcc/rust/hir/tree/rust-hir-visitor.h and use the reported backtrace to trace the failing visitor path. Done means the reproducer no longer causes a 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.