Skip to content

Conversation

@ZenasSong
Copy link

Changes thread_stack_size from usize to Option<usize> to address concerns about safety and platform compatibility.

Key improvements:

  • Default to None, using Rust std's default stack size (typically 2MB)
  • Only apply custom stack size when explicitly configured
  • Safer for user callbacks with unpredictable stack requirements
  • Platform-agnostic (handles 32-bit vs 64-bit differences automatically)
  • Marked as an advanced option in documentation with appropriate warnings

This addresses the feedback from PR #3885 about hardcoded stack sizes being unsafe due to:

  1. Unpredictable stack needs of user-supplied callbacks
  2. Platform-specific requirements (32-bit vs 64-bit)
  3. Need for conservative defaults

Related: #3885

Does your PR solve an issue?

Delete this text and add "fixes #(issue number)".

Do not just list issue numbers here as they will not be automatically closed on merging this pull request unless prefixed with "fixes" or "closes".

Is this a breaking change?

Delete this text and answer yes/no and explain.

If yes, this pull request will need to wait for the next major release (0.{x + 1}.0)

Behavior changes can be breaking if significant enough.
Consider Hyrum's Law:

With a sufficient number of users of an API,
it does not matter what you promise in the contract:
all observable behaviors of your system
will be depended on by somebody.

Changes `thread_stack_size` from `usize` to `Option<usize>` to address concerns about safety and platform compatibility. Key improvements: - Default to `None`, using Rust std's default stack size (typically 2MB) - Only apply custom stack size when explicitly configured - Safer for user callbacks with unpredictable stack requirements - Platform-agnostic (handles 32-bit vs 64-bit differences automatically) - Marked as an advanced option in documentation with appropriate warnings This addresses the feedback from PR launchbadge#3885 about hardcoded stack sizes being unsafe due to: 1. Unpredictable stack needs of user-supplied callbacks 2. Platform-specific requirements (32-bit vs 64-bit) 3. Need for conservative defaults Related: launchbadge#3885
@abonander
Copy link
Collaborator

@ZenasSong please run cargo fmt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants