-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Ensure TLS destructors run before thread joins in SGX #84409
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
r? @dtolnay (rust-highfive has picked a reviewer for you, use r? to override) |
950ea0d
to
5d9eeff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this 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.
@bors r+ |
📌 Commit 5d9eeff has been approved by |
…r=dtolnay Ensure TLS destructors run before thread joins in SGX The excellent test is from `@jethrogb` For context see: rust-lang#83416 (comment)
…r=dtolnay Ensure TLS destructors run before thread joins in SGX The excellent test is from ``@jethrogb`` For context see: rust-lang#83416 (comment)
…r=dtolnay Ensure TLS destructors run before thread joins in SGX The excellent test is from ```@jethrogb``` For context see: rust-lang#83416 (comment)
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.
6af18d7
to
8a0a4b1
Compare
Ping for review |
@jethrogb I think you need @ with your bors command. |
@bors r+ |
📌 Commit 2acd62d has been approved by |
…r=jethrogb Ensure TLS destructors run before thread joins in SGX The excellent test is from `@jethrogb` For context see: rust-lang#83416 (comment)
…r=jethrogb Ensure TLS destructors run before thread joins in SGX The excellent test is from ``@jethrogb`` For context see: rust-lang#83416 (comment)
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
@rustbot modify labels: +beta-nominated |
Error: Label beta-nominated can only be set by Rust team members Please let |
@rustbot labels +beta-nominated |
…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
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), | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
The excellent test is from @jethrogb
For context see: #83416 (comment)