Skip to content

std::thread docs are unclear regarding stack sizes #102671

Closed
@steveklabnik

Description

@steveklabnik

Location

https://doc.rust-lang.org/std/thread/#stack-size

Summary

This says

The default stack size for spawned threads is 2 MiB, though this particular stack size is subject to change in the future.

This is not correct, because it implies this is true for all platforms, but each platform sets their own default stack size. Even amongst unices, 2mib isn't always the case.

#[cfg(not(any(target_os = "l4re", target_os = "vxworks", target_os = "espidf")))]
pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024;
#[cfg(target_os = "l4re")]
pub const DEFAULT_MIN_STACK_SIZE: usize = 1024 * 1024;
#[cfg(target_os = "vxworks")]
pub const DEFAULT_MIN_STACK_SIZE: usize = 256 * 1024;
#[cfg(target_os = "espidf")]
pub const DEFAULT_MIN_STACK_SIZE: usize = 0; // 0 indicates that the stack size configured in the ESP-IDF menuconfig system should be used

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and tools

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions