Skip to content

segfault in parsing / parse_stmt_or_expr #3974

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use
impl<'a, F> RunUntil<'a, F> {
    fn project<'pin>() -> Projection<'pin, 'a, F> {
        Self!()
    }
}
original code

original:

//@ edition:2018
//@ revisions: rpass1


// Regression test for #86753. The `type_implements_trait` query (since moved to a method)
// was encountering an ICE during incremental testing when hashing its arguments.
#![warn(rust_2021_compatibility)]

use std::future::Future;
use std::pin::Pin;
use std::task::{Poll, Context};

struct LocalSet {}
struct RunUntil<'a, F> {
    _local_set: &'a LocalSet,
    _future: F,
}
impl<'a, F> RunUntil<'a, F> {
    fn project<'pin>(self: Pin<&'pin mut Self>) -> Projection<'pin, 'a, F> {
        Self!()
    }
}

struct Projection<'pin, 'a, F>
where
    RunUntil<'a, F>: 'pin,
{
    pub local_set: &'pin mut &'a LocalSet,
    pub future: Pin<&'pin mut F>,
}

impl LocalSet {
    fn withwith(&self, _f: impl FnOnce() -> T) -> T {
        unimplemented!()
    }
}
impl<T: Future> Future for RunUntil<'_, T> {
    type Output = T::Output;
    fn poll(self: Pin<&mut Self>, cx: &mut Output<'_>) -> Poll<Self::Output> {
        let me = self.project();
        me.local_set.with(|| {
            let _ = cx.waker();
            let f = me.future;
            let _ = f.future(cx);
            Poll::Pending
        })
    }
}

fn main(self: Pin<&'pin mut Self>) {}

Version information:

5dc8c4d

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
0x2fecaf8 internal_error(char const*, ...)
	../../gcc/diagnostic-global-context.cc:517
0x196d57f crash_signal
	../../gcc/toplev.cc:321
0xd09268 Rust::Parser<Rust::Lexer>::parse_stmt_or_expr()
	../../gcc/rust/parse/rust-parse-impl.h:11693
0xd09446 Rust::Parser<Rust::Lexer>::parse_block_expr(std::vector<Rust::AST::Attribute, std::allocator<Rust::AST::Attribute> >, tl::optional<Rust::AST::LoopLabel>, unsigned long)
	../../gcc/rust/parse/rust-parse-impl.h:7221
0xd2d357 Rust::Parser<Rust::Lexer>::parse_inherent_impl_function_or_method(Rust::AST::Visibility, std::vector<Rust::AST::Attribute, std::allocator<Rust::AST::Attribute> >)
	../../gcc/rust/parse/rust-parse-impl.h:5651
0xd33d0a Rust::Parser<Rust::Lexer>::parse_inherent_impl_item()
	../../gcc/rust/parse/rust-parse-impl.h:5532
0xd05c93 Rust::Parser<Rust::Lexer>::parse_impl(Rust::AST::Visibility, std::vector<Rust::AST::Attribute, std::allocator<Rust::AST::Attribute> >)
	../../gcc/rust/parse/rust-parse-impl.h:5338
0xd07773 Rust::Parser<Rust::Lexer>::parse_vis_item(std::vector<Rust::AST::Attribute, std::allocator<Rust::AST::Attribute> >)
	../../gcc/rust/parse/rust-parse-impl.h:1420
0xd3fe5a Rust::Parser<Rust::Lexer>::parse_item(bool)
	../../gcc/rust/parse/rust-parse-impl.h:1153
0xd40195 Rust::Parser<Rust::Lexer>::parse_items()
	../../gcc/rust/parse/rust-parse-impl.h:427
0xdbe7ed Rust::Parser<Rust::Lexer>::parse_crate()
	../../gcc/rust/parse/rust-parse-impl.h:456
0xdb8d37 Rust::Session::compile_crate(char const*)
	../../gcc/rust/rust-session-manager.cc:547
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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions