-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Description
I tried this code:
https://github.com/JakubKoralewski/repro-rust-asyncdrop-stack-overflow/blob/main/src/main.rs
I expected to see this happen:
no error
Instead, this happened:
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.03s
Running `/mnt/vol/.cargo/target/debug/async-drop-stack-overflow-repro`
1889328 (1845 KB)
thread 'main' (3359453) has overflowed its stack
fatal runtime error: stack overflow, aborting
Aborted (core dumped)
Just adding the feature at the top of the file causes the stack overflow. It's not necessary to even implement Drop/AsyncDrop.
Massaging this line :
let mut x = [ 0; 30 * 1024];
1889296 (1845 KB)
into 20*1024 fixes it:
1807376 (1765 KB)
1
1
1
Meta
rustc --version --verbose:
$ rustc --version --verbose
rustc 1.94.0-nightly (56f24e00c 2025-12-29)
binary: rustc
commit-hash: 56f24e00c62ec2db9a8b407e7aef532caaf71062
commit-date: 2025-12-29
host: aarch64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.8
Edit
I think causes may be an overstatement. I must have had an already large async fn call tree, and AsyncDrop seems to add a little bit more to the stack size and probably was the straw that broke the camels back.
I can't reproduce this particular behavior in the reproduction, but I've been trying to keep AsyncDrop in my original code, and started calling .boxed(), .boxed_local() on some futures, removing some SmallVecs to Vecs, but even then I couldn't get it to work :/ Even added a new error to the collection:
Caused by:
process didn't exit successfully: `/mnt/vol/.cargo/target/debug/deps/single_step-8ac7d03d04480459 test_data_run_all_single_step --exact --show-output --nocapture` (signal: 7, SIGBUS: access to undefined memory)
I've seen SIGSEGV before as the first step of the stack overflow, but this is new. (error disappers when I disable AsyncDrop)