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

task: illumos/Solaris have thread-local weirdness #6777

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions tokio/src/task/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1160,9 +1160,15 @@ impl LocalState {

#[track_caller]
fn assert_called_from_owner_thread(&self) {
// FreeBSD has some weirdness around thread-local destruction.
// BSDs, illumos, and Solaris have some weirdness around thread-local
// destruction.
// TODO: remove this hack when thread id is cleaned up
#[cfg(not(any(target_os = "openbsd", target_os = "freebsd")))]
#[cfg(not(any(
Comment on lines -1163 to +1166
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, the actual code looks like this:

            context::thread_id()
                .map(|id| id == self.owner)
                .unwrap_or(true),

here it's using map to handle the case where getting the thread local fails. Not sure why these platforms fail in some other way. Anyway, since we already need this for other platforms, it doesn't seem like an issue to add more platforms here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, if memory serves, the problem is actually that on BSDs (and apparently, illumos/Solaris), getting the thread local apparently doesn't fail as we would expect, and it instead gets a new value or something. I vaguely recall @carllerche trying to figure this out while working on #5179, and I think we couldn't really figure out what was going on there and kinda gave up...

target_os = "openbsd",
target_os = "freebsd",
target_os = "illumos",
target_os = "solaris",
)))]
debug_assert!(
// if we couldn't get the thread ID because we're dropping the local
// data, skip the assertion --- the `Drop` impl is not going to be
Expand Down
Loading