Skip to content

Segmentation fault in async recursion #125

Description

@dullbananas

To reproduce:

use std::future::Future;

#[inline(never)]
async fn recurse(n: usize) {
    let x = [77u8; 70000];
    if n != 0 {
        std::future::poll_fn(move |cx| {
            stacker::maybe_grow(140 * 1024, 8 * 1024, move || {
                Box::pin(recurse(n - 1)).as_mut().poll(cx)
            })
        })
        .await;
    }
    #[allow(dropping_copy_types)]
    drop(x);
}

#[test]
fn foof() {
    futures_lite::future::block_on(recurse(10000))
}

Error message:

process didn't exit successfully: `/home/dullbananas/Dropbox/stacker/target/debug/deps/segfault-6753b3a3d075b2b5 foof --exact --show-output` (signal: 11, SIGSEGV: invalid memory reference)

cargo 1.86.0 (adf9b6ad1 2025-02-28)

Linux 6.14.5-300.t2.fc42.x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions