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

Remove unnecessary fixme on new thread stack size #122088

Merged
merged 2 commits into from
Mar 7, 2024

Conversation

ChrisDenton
Copy link
Member

@ChrisDenton ChrisDenton commented Mar 6, 2024

As the FIXME itself notes, there's nothing to fix here.

And as the documentation for CreateThread says of dwStackSize, the value is rounded up to the nearest page. A 4kb stack is very small but perfectly usable if you're careful. Of course it will be very limited but there's no reason to add artificial limits. We don't know what the user is doing.

As the FIXME itself notes, there's nothing to fix here.
@rustbot rustbot added O-windows Operating system: Windows S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Mar 6, 2024
@workingjubilee
Copy link
Member

As the FIXME itself notes, there's nothing to fix here.

And as the documentation for CreateThread says of dwStackSize, the value is rounded up to the nearest page. A 4kb stack is very small but perfectly usable if you're careful. Of course it will be very limited but there's no reason to add artificial limits. We don't know what the user is doing.

Also important is that a 0, which would be rounded up to the nearest page size of 0, actually is treated as the "default thread stack size". Please fix this to the more minimal comment that mentions both of these things, i.e. "this is either at least PAGE_SIZE or a default value", so that someone can skip consulting the MSDN docs for that.

Does starting a thread using a 4KB stack actually succeed? Do we have a test for this? I would like to see a test if we do not. Obviously, for such a test, the thread doesn't have to do anything meaningful: it's fine if it basically runs AtomicInt::fetch_add, returns the read value, and and then dies, which I think would be a valid thread to run inside such a tiny stack. Just as long as the thread spawn isn't elided by LLVM somehow and it does in fact successfully start and finish this hypothetical virtually no-op program.

@ChrisDenton
Copy link
Member Author

Sure, I can replace it with a useful comment and add a test.

@rust-log-analyzer

This comment has been minimized.

@workingjubilee
Copy link
Member

Thanks! That's fucking wild that that works.

r? @workingjubilee

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Mar 6, 2024

📌 Commit 8718317 has been approved by workingjubilee

It is now in the queue for this repository.

@rustbot rustbot assigned workingjubilee and unassigned m-ou-se Mar 6, 2024
@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 6, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 7, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#122015 (Add better explanation for `rustc_index::IndexVec`)
 - rust-lang#122061 (Clarify FatalErrorHandler)
 - rust-lang#122062 (Explicitly assign constructed C++ classes)
 - rust-lang#122072 (Refer to "slice" instead of "vector" in Ord and PartialOrd trait impl of slices)
 - rust-lang#122088 (Remove unnecessary fixme on new thread stack size)
 - rust-lang#122094 (Remove outdated footnote "missing-stack-probe" in platform-support)
 - rust-lang#122107 (Temporarily make allow-by-default the `non_local_definitions` lint)
 - rust-lang#122109 (compiletest: Add a `//@ needs-threads` directive)

Failed merges:

 - rust-lang#122104 (Rust is a proper name: rust → Rust)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 7220e52 into rust-lang:master Mar 7, 2024
11 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Mar 7, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 7, 2024
Rollup merge of rust-lang#122088 - ChrisDenton:fixme, r=workingjubilee

Remove unnecessary fixme on new thread stack size

As the FIXME itself notes, there's nothing to fix here.

And as the documentation for [`CreateThread`] says of `dwStackSize`, the value is rounded up to the nearest page. A 4kb stack is very small but perfectly usable if you're careful. Of course it will be very limited but there's no reason to add artificial limits. We don't know what the user is doing.

[`CreateThread`]: https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createthread
@ChrisDenton ChrisDenton deleted the fixme branch March 7, 2024 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-windows Operating system: Windows S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants