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

Ensure TLS destructors run before thread joins in SGX #84409

Merged
merged 3 commits into from
May 7, 2021

Conversation

mzohreva
Copy link
Contributor

The excellent test is from @jethrogb

For context see: #83416 (comment)

@rust-highfive
Copy link
Collaborator

r? @dtolnay

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 21, 2021
Copy link
Contributor

@jethrogb jethrogb left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thanks -- accepting without particular scrutiny on the basis of @jethrogb's review.

@dtolnay
Copy link
Member

dtolnay commented Apr 22, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Apr 22, 2021

📌 Commit 5d9eeff has been approved by dtolnay

@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 Apr 22, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Apr 23, 2021
…r=dtolnay

Ensure TLS destructors run before thread joins in SGX

The excellent test is from `@jethrogb`

For context see: rust-lang#83416 (comment)
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Apr 23, 2021
…r=dtolnay

Ensure TLS destructors run before thread joins in SGX

The excellent test is from ``@jethrogb``

For context see: rust-lang#83416 (comment)
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Apr 24, 2021
…r=dtolnay

Ensure TLS destructors run before thread joins in SGX

The excellent test is from ```@jethrogb```

For context see: rust-lang#83416 (comment)
@Dylan-DPC-zz
Copy link

fails in rollup

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 24, 2021
std::sync::mpsc uses thread locals and depending on the order TLS dtors
are run `rx.recv()` can panic when used in a TLS dtor.
@mzohreva
Copy link
Contributor Author

@dtolnay this is ready for another look.

@rustbot modify labels to +S-waiting-on-review, -S-waiting-on-author

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 30, 2021
@jethrogb
Copy link
Contributor

jethrogb commented May 4, 2021

Ping for review

@mzohreva
Copy link
Contributor Author

mzohreva commented May 6, 2021

@jethrogb I think you need @ with your bors command.

@jethrogb
Copy link
Contributor

jethrogb commented May 6, 2021

@bors r+

@bors
Copy link
Contributor

bors commented May 6, 2021

📌 Commit 2acd62d has been approved by jethrogb

@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 May 6, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request May 6, 2021
…r=jethrogb

Ensure TLS destructors run before thread joins in SGX

The excellent test is from `@jethrogb`

For context see: rust-lang#83416 (comment)
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request May 6, 2021
…r=jethrogb

Ensure TLS destructors run before thread joins in SGX

The excellent test is from ``@jethrogb``

For context see: rust-lang#83416 (comment)
bors added a commit to rust-lang-ci/rust that referenced this pull request May 7, 2021
Rollup of 11 pull requests

Successful merges:

 - rust-lang#84409 (Ensure TLS destructors run before thread joins in SGX)
 - rust-lang#84500 (Add --run flag to compiletest)
 - rust-lang#84728 (Add test for suggestion to borrow unsized function parameters)
 - rust-lang#84734 (Add `needs-unwind` and beginning of support for testing `panic=abort` std to compiletest)
 - rust-lang#84755 (Allow using `core::` in intra-doc links within core itself)
 - rust-lang#84871 (Disallows `#![feature(no_coverage)]` on stable and beta (using standard crate-level gating))
 - rust-lang#84872 (Wire up tidy dependency checks for cg_clif)
 - rust-lang#84896 (Handle incorrect placement of parentheses in trait bounds more gracefully)
 - rust-lang#84905 (CTFE engine: rename copy → copy_intrinsic, move to intrinsics.rs)
 - rust-lang#84953 (Remove unneeded call to with_default_session_globals in rustdoc highlight)
 - rust-lang#84987 (small nits)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit b30e428 into rust-lang:master May 7, 2021
@rustbot rustbot added this to the 1.54.0 milestone May 7, 2021
@mzohreva mzohreva deleted the mz/tls-dtors-before-join branch May 7, 2021 04:00
@jethrogb
Copy link
Contributor

jethrogb commented May 7, 2021

@rustbot modify labels: +beta-nominated

@rustbot
Copy link
Collaborator

rustbot commented May 7, 2021

Error: Label beta-nominated can only be set by Rust team members

Please let @rust-lang/release know if you're having trouble with this bot.

@apiraino
Copy link
Contributor

apiraino commented May 7, 2021

@rustbot labels +beta-nominated

@apiraino apiraino added beta-nominated Nominated for backporting to the compiler in the beta channel. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 7, 2021
@apiraino
Copy link
Contributor

Beta backport approved as per compiler team on Zulip

@rustbot label +beta-accepted

@rustbot rustbot added the beta-accepted Accepted for backporting to the compiler in the beta channel. label May 20, 2021
@Mark-Simulacrum Mark-Simulacrum modified the milestones: 1.54.0, 1.53.0 May 22, 2021
@Mark-Simulacrum Mark-Simulacrum removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label May 22, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request May 22, 2021
…ulacrum

[beta] backports

 * Backport 1.52.1 release notes rust-lang#85404
 * remove InPlaceIterable marker from Peekable due to unsoundness rust-lang#85340
 * rustdoc: Call initSidebarItems in root module of crate rust-lang#85304
 * Update LLVM submodule rust-lang#85236
 * Do not ICE on invalid const param rust-lang#84913
 * Disallows #![feature(no_coverage)] on stable and beta (using standard crate-level gating) rust-lang#84871
 * Ensure TLS destructors run before thread joins in SGX rust-lang#84409
Comment on lines +300 to +313
match SYNC_STATE.compare_exchange_weak(
THREAD1_WAITING,
MAIN_THREAD_RENDEZVOUS,
Ordering::SeqCst,
Ordering::SeqCst,
) {
Ok(_) => break,
Err(FRESH) => thread::yield_now(),
Err(THREAD2_LAUNCHED) => thread::yield_now(),
Err(THREAD2_JOINED) => {
panic!("Main thread rendezvous after thread 2 joined thread 1")
}
v => unreachable!("sync state: {:?}", v),
}
Copy link
Contributor

@tmiasko tmiasko Jun 18, 2021

Choose a reason for hiding this comment

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

compare_exchange_weak allows spurious failures. If the current value is THREAD1_WAITING but operation fails, the code will enter last unreachable branch and panic.

Copy link
Contributor

Choose a reason for hiding this comment

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

We observed this failure in #89584 on armhf Debian, I have started a re-try of the build to see if the error goes away. But yes it should be fixed so it never occurs.

Copy link
Contributor

Choose a reason for hiding this comment

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

This was already fixed in #86383 so you must've observed a different failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.