Stack overflow with panic=unwind but OK with panic=abort

⚓ rust    📅 2025-05-21    👤 surdeus    👁️ 4      

surdeus

Warning

This post was published 39 days ago. The information described in this article may have changed.

Hi folks,

I have a program that needs a large stack (for a good reason).

When I run cargo run ... on x86 Linux:

with

use tokio::runtime::Builder;

fn main() {
    Builder::new_multi_thread()
        .thread_stack_size(2 * 1024 * 1024)
        .enable_io()
        .enable_time()
        .build()
        .unwrap()
        .block_on(my_function())
}

and

[profile.dev]
overflow-checks = true
opt-level = 0
panic = 'abort'

It works OK. But when I change it to:

fn main() {
    Builder::new_multi_thread()
        .thread_stack_size(1024 * 1024 * 1024) // crazy large
        .enable_io()
        .enable_time()
        .build()
        .unwrap()
        .block_on(my_function())
}

and

[profile.dev]
overflow-checks = true
opt-level = 0
panic = 'unwind'

I get

thread 'main' has overflowed its stack
fatal runtime error: stack overflow

Does it make sense?

Thank you!

1 post - 1 participant

Read full topic

🏷️ rust_feed