rust-lang / rust-lang/stacker

Segmentation fault in async recursion

Open
#125 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
360
Forks
78
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

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 provided async recursion test on the reported Linux and Rust versions, then inspect how stacker::maybe_grow interacts with the nested poll calls and large local array. Reproduce the SIGSEGV and trace the stack-growth path; done means the test completes without a segmentation fault or the issue is narrowed to a documented limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.