Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump the minimum stack size to at least 1MB #1139

Merged
merged 9 commits into from
Jul 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions source/posix/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,25 @@ int aws_thread_launch(
if (attr_return) {
goto cleanup;
}
} else if (!options->stack_size) {
/**
* On some systems, the default stack size is too low (128KB on musl at the time of writing this), which can
* cause stack overflow when the dependency chain is long. Increase the stack size to at
* least 1MB, which is the default on Windows.
*/
size_t min_stack_size = (size_t)1 * 1024 * 1024;
size_t current_stack_size;
attr_return = pthread_attr_getstacksize(attributes_ptr, &current_stack_size);
if (attr_return) {
goto cleanup;
}

if (current_stack_size < min_stack_size) {
attr_return = pthread_attr_setstacksize(attributes_ptr, min_stack_size);
if (attr_return) {
goto cleanup;
}
}
}

/* AFAIK you can't set thread affinity on apple platforms, and it doesn't really matter since all memory
Expand Down
Loading