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-local keyless drop #90442

Merged
merged 2 commits into from
Nov 2, 2021
Merged

Conversation

ChrisDenton
Copy link
Member

#[thread_local] allows us to maintain a per-thread list of destructors. This also avoids the need to synchronize global data (which is particularly tricky within the TLS callback function).

r? @alexcrichton

`#[thread_local]` allows us to maintain a per-thread list of destructors. This also avoids the need to synchronize global data (which is particularly tricky within the TLS callback function).
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 31, 2021
// The short version is that all the function pointers in the `.CRT$XL*` array
// will be called whenever a thread or process starts or ends.

#[link_section = ".CRT$XLD"]
Copy link
Member

Choose a reason for hiding this comment

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

This all seems pretty reasonable to me! Could the previously-registered "at thread exit" function get a new hook to call into this module though? I think it 'd probably be best to avoid these #[link_section] annotations if we can and have them consolidated into one place if possible.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I've used a normal Rust function for running the new dtors and simply made the exit function call it. Is this what you had in mind?

library/std/src/sys/windows/thread_local_dtor.rs Outdated Show resolved Hide resolved
@rust-log-analyzer

This comment has been minimized.

@alexcrichton
Copy link
Member

@bors: r+

Looks great to me!

@bors
Copy link
Contributor

bors commented Nov 1, 2021

📌 Commit 1048651 has been approved by alexcrichton

@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 Nov 1, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 1, 2021
…chton

Windows thread-local keyless drop

`#[thread_local]` allows us to maintain a per-thread list of destructors. This also avoids the need to synchronize global data (which is particularly tricky within the TLS callback function).

r? `@alexcrichton`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 2, 2021
…chton

Windows thread-local keyless drop

`#[thread_local]` allows us to maintain a per-thread list of destructors. This also avoids the need to synchronize global data (which is particularly tricky within the TLS callback function).

r? ``@alexcrichton``
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 2, 2021
…chton

Windows thread-local keyless drop

`#[thread_local]` allows us to maintain a per-thread list of destructors. This also avoids the need to synchronize global data (which is particularly tricky within the TLS callback function).

r? ```@alexcrichton```
@bors
Copy link
Contributor

bors commented Nov 2, 2021

⌛ Testing commit 1048651 with merge c3190c1...

@bors
Copy link
Contributor

bors commented Nov 2, 2021

☀️ Test successful - checks-actions
Approved by: alexcrichton
Pushing c3190c1 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 2, 2021
@bors bors merged commit c3190c1 into rust-lang:master Nov 2, 2021
@rustbot rustbot added this to the 1.58.0 milestone Nov 2, 2021
@ChrisDenton ChrisDenton deleted the win-tls-dtor branch November 2, 2021 15:25
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (c3190c1): comparison url.

Summary: This benchmark run did not return any relevant changes.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants