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

Windows thread support: Part 1 #2231

Merged
merged 5 commits into from
Aug 18, 2022
Merged

Windows thread support: Part 1 #2231

merged 5 commits into from
Aug 18, 2022

Conversation

beepster4096
Copy link
Contributor

@beepster4096 beepster4096 commented Jun 13, 2022

This PR adds support for threads on Windows.

@beepster4096 beepster4096 force-pushed the winfred branch 2 times, most recently from a8f777b to ecdcbd0 Compare June 13, 2022 05:20
@beepster4096
Copy link
Contributor Author

Whoops, I messed up the rebase at first.

Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to run ./miri bless, too, in order to update the .stderr files. You may have to run this for multiple targets to make sure they're all in sync in their behaviour

src/thread.rs Show resolved Hide resolved
src/shims/windows/sync.rs Outdated Show resolved Hide resolved
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Jun 14, 2022
…hrisDenton

Fix compat_fn option method on miri

This change is required to make `WaitOnAddress` work with rust-lang/miri#2231
@beepster4096
Copy link
Contributor Author

I've rewritten the handle implementation based on what is actually guaranteed by the windows docs

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Jun 14, 2022
…hrisDenton

Fix compat_fn option method on miri

This change is required to make `WaitOnAddress` work with rust-lang/miri#2231
@RalfJung
Copy link
Member

If it helps, here are some public resources on HANDLEs:

To the extent that these are relevant for this new code in Miri, please add links to them in comments in the code. :)

@bors
Copy link
Contributor

bors commented Jun 16, 2022

☔ The latest upstream changes (presumably #2236) made this pull request unmergeable. Please resolve the merge conflicts.

src/shims/windows/sync.rs Outdated Show resolved Hide resolved
@RalfJung
Copy link
Member

Thanks for the PR! Looks like Windows is starting to catch up with our Linux support. :)

I am working on a review, but in the future it'd be helpful to break PRs into smaller chunks. For example, I think this could have started with just thread spawning and joining, without all the concurrency primitives. Smaller PRs are a lot easier to review so any effort you can put into splitting a change into chunks is much appreciated.

Copy link
Member

@RalfJung RalfJung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great overall, very nice!

I hope all the new code you added is actually covered by tests. For thread spawning and the synchronization primitives, I would think the existing sync tests are enough, though I do not know if the stdlib actually uses these primitives.

I did not see a test that would join on a thread with a timeout, so that will have to be added (or the code for that be removed again). Also there are no new failing tests, which is a bit of a concern given that the pthreads primitives have a lot of failing tests to ensure that misuse of the pthread APIs is detected.

src/sync.rs Outdated Show resolved Hide resolved
src/sync.rs Outdated Show resolved Hide resolved
src/thread.rs Outdated Show resolved Hide resolved
src/thread.rs Outdated Show resolved Hide resolved
src/thread.rs Outdated Show resolved Hide resolved
src/shims/windows/thread.rs Outdated Show resolved Hide resolved
src/shims/windows/sync.rs Outdated Show resolved Hide resolved
src/shims/windows/sync.rs Outdated Show resolved Hide resolved
tests/fail/concurrency/thread_local_static_dealloc.rs Outdated Show resolved Hide resolved
tests/pass/concurrency/tls_lib_drop.rs Outdated Show resolved Hide resolved
@bors
Copy link
Contributor

bors commented Jul 8, 2022

☔ The latest upstream changes (presumably #2332) made this pull request unmergeable. Please resolve the merge conflicts.

@RalfJung
Copy link
Member

RalfJung commented Jul 9, 2022

Looking at your commits, I see "basic threading" and "condvar, parking and yielding" are separate commits. If you could split those into separate PRs, that would help a lot with reviewing.

Basically the first PR just needs to get concurrency/{simple,thread_local,tls*}.rs to work. That should be possible without new synchronization code I hope?

@RalfJung
Copy link
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: Waiting for the PR author to address review comments and removed S-waiting-on-review Status: Waiting for a review to complete labels Aug 14, 2022
@beepster4096 beepster4096 force-pushed the winfred branch 2 times, most recently from 8a6c1f8 to f010307 Compare August 14, 2022 04:32
@beepster4096
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Waiting for a review to complete and removed S-waiting-on-author Status: Waiting for the PR author to address review comments labels Aug 14, 2022
src/thread.rs Outdated Show resolved Hide resolved
@RalfJung
Copy link
Member

Just two more comment nits, then we are good to go. :) Since review is done, please squash the commits together a bit.

@RalfJung
Copy link
Member

@rustbot author

@bors
Copy link
Contributor

bors commented Aug 18, 2022

☔ The latest upstream changes (presumably #2492) made this pull request unmergeable. Please resolve the merge conflicts.

@beepster4096
Copy link
Contributor Author

@rustbot ready

@RalfJung
Copy link
Member

Awesome, thanks a ton for all your work and patience. :)

@bors r+

@bors
Copy link
Contributor

bors commented Aug 18, 2022

📌 Commit c466ac0 has been approved by RalfJung

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Aug 18, 2022

⌛ Testing commit c466ac0 with merge 46da748...

@bors
Copy link
Contributor

bors commented Aug 18, 2022

☀️ Test successful - checks-actions
Approved by: RalfJung
Pushing 46da748 to master...

@bors bors merged commit 46da748 into rust-lang:master Aug 18, 2022
workingjubilee pushed a commit to tcdi/postgrestd that referenced this pull request Sep 15, 2022
Fix compat_fn option method on miri

This change is required to make `WaitOnAddress` work with rust-lang/miri#2231
bors added a commit that referenced this pull request Nov 6, 2022
Implement condvars for Windows

Adds 3 shims for Windows: `SleepConditionVariableSRW`, `WakeConditionVariable`, `WakeAllConditionVariable` to add support for condvars (which fixes #2628).

Salvaged from what was removed from #2231
RalfJung pushed a commit to RalfJung/miri that referenced this pull request Nov 15, 2022
Implement condvars for Windows

Adds 3 shims for Windows: `SleepConditionVariableSRW`, `WakeConditionVariable`, `WakeAllConditionVariable` to add support for condvars (which fixes rust-lang#2628).

Salvaged from what was removed from rust-lang#2231
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Waiting for a review to complete
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants