Skip to content

Rustc endless loop out-of-memory and consequent SIGKILL in generic new type #67690

Closed
@dangerousplay

Description

@dangerousplay

Hi, i have made some changes for a crate stubborn-io to support a generic type that implements ToSocketAddrs from Tokio, but suddenly the code can't compile because it runs out of memory with 6, 8, 10 GB.

This is the code i'm trying to compile:

use super::io::{StubbornIo, UnderlyingIo};
use std::future::Future;
use std::io;
use tokio::net::ToSocketAddrs;
use std::pin::Pin;
use tokio::net::TcpStream;

impl<A> UnderlyingIo<A> for TcpStream
where A: ToSocketAddrs + Sync + Send + Clone + Unpin + 'static {
    fn establish(addr: A) -> Pin<Box<dyn Future<Output = io::Result<Self>> + Send>> {
        Box::pin(TcpStream::connect(addr))
    }
}

pub type StubbornTcpStream<A: ToSocketAddrs + Sync + Send + Clone + Unpin + 'static> = StubbornIo<TcpStream, A>;

if changed the type A for SocketAddr or String it then compiles and runs fine.

Source: https://github.com/dangerousplay/stubborn-io/blob/64bad09fbb398ceca0add972399cddd04751e378/src/tokio/tcp.rs#L1-L29

It fails to compile on x86_64-unknown-linux-gnu with stable, nightly.

I'm attaching the Heaptrack files for further analysis.
https://gofile.io/?c=Vnar2K

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions