Skip to content

queue: use the default stack size on Windows #522

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

Merged
merged 1 commit into from
Sep 23, 2019
Merged

queue: use the default stack size on Windows #522

merged 1 commit into from
Sep 23, 2019

Conversation

adierking
Copy link
Contributor

The Windows thread pool implementation is calling _beginthreadex with
a stack size of 64 KB. This seems like a misunderstanding to me. In the
pthread code, _dispatch_mgr_root_queue_init does call
pthread_attr_setstacksize with a 64 KB size. However, this only
applies to the pthread root queue manager, and pthread root queues are
only supported on Apple platforms anyway.

We can confirm that using the OS default stack size is the intended
semantic by looking at the dispatch_select test, which expects to be
able to stack-allocate a 500 KB buffer in an event handler. This test is
failing on Windows because there is not enough stack space. We've also
run into various related issues in Swift which only happen on Windows,
and I suspect that this is just because the stack size isn't so small on
other platforms.

The Windows thread pool implementation is calling `_beginthreadex` with
a stack size of 64 KB. This seems like a misunderstanding to me. In the
pthread code, `_dispatch_mgr_root_queue_init` does call
`pthread_attr_setstacksize` with a 64 KB size. However, this only
applies to the pthread root queue manager, and pthread root queues are
only supported on Apple platforms anyway.

We can confirm that using the OS default stack size is the intended
semantic by looking at the `dispatch_select` test, which expects to be
able to stack-allocate a 500 KB buffer in an event handler. This test is
failing on Windows because there is not enough stack space. We've also
run into various related issues in Swift which only happen on Windows,
and I suspect that this is just because the stack size isn't so small on
other platforms.
@adierking
Copy link
Contributor Author

cc @compnerd @ktopley-apple

@compnerd
Copy link
Member

@swift-ci please test

@compnerd
Copy link
Member

@compnerd compnerd merged commit 289e552 into swiftlang:master Sep 23, 2019
rokhinip pushed a commit that referenced this pull request Nov 5, 2021
queue: use the default stack size on Windows
Signed-off-by: Rokhini Prabhu <rokhinip@apple.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants