-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Use the OS thread name by default if THREAD_INFO
has not been initialized
#121666
Conversation
THREAD_INFO
has not been initialized
9b7e102
to
f3546a2
Compare
f3546a2
to
c84ba23
Compare
@bors r+ |
Use the OS thread name by default if `THREAD_INFO` has not been initialized Currently if `THREAD_INFO` hasn't been initialized then the name will be set to `None`. This PR changes it to use the OS thread name by default. This mostly affects foreign threads at the moment but we could expand this to make more use of the OS thread name in the future. Note: I've only implemented `Thread::get_name` for windows, linux and macos (and macos adjacent) targets. The rest just return `None`.
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#121194 (Refactor pre-getopts command line argument handling) - rust-lang#121666 (Use the OS thread name by default if `THREAD_INFO` has not been initialized) - rust-lang#121758 (Move thread local implementation to `sys`) - rust-lang#121759 (attempt to further clarify addr_of docs) - rust-lang#121888 (style library/core/src/error.rs) - rust-lang#121892 (The ordinary lowering of `thir::ExprKind::Let` is unreachable) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#121666 (Use the OS thread name by default if `THREAD_INFO` has not been initialized) - rust-lang#121758 (Move thread local implementation to `sys`) - rust-lang#121759 (attempt to further clarify addr_of docs) - rust-lang#121855 (Correctly generate item info of trait items) - rust-lang#121888 (style library/core/src/error.rs) - rust-lang#121892 (The ordinary lowering of `thir::ExprKind::Let` is unreachable) - rust-lang#121895 (avoid collecting into vecs in some places) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#121666 (Use the OS thread name by default if `THREAD_INFO` has not been initialized) - rust-lang#121758 (Move thread local implementation to `sys`) - rust-lang#121759 (attempt to further clarify addr_of docs) - rust-lang#121855 (Correctly generate item info of trait items) - rust-lang#121888 (style library/core/src/error.rs) - rust-lang#121892 (The ordinary lowering of `thir::ExprKind::Let` is unreachable) - rust-lang#121895 (avoid collecting into vecs in some places) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#121666 - ChrisDenton:thread-name, r=cuviper Use the OS thread name by default if `THREAD_INFO` has not been initialized Currently if `THREAD_INFO` hasn't been initialized then the name will be set to `None`. This PR changes it to use the OS thread name by default. This mostly affects foreign threads at the moment but we could expand this to make more use of the OS thread name in the future. Note: I've only implemented `Thread::get_name` for windows, linux and macos (and macos adjacent) targets. The rest just return `None`.
Thread::set_name(name); | ||
assert_eq!(name, Thread::get_name().unwrap().as_c_str()); | ||
}); | ||
handler.join().unwrap(); |
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.
Is there a particular reason why this test runs in a new thread, rather than the main thread?
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.
I was worried about affecting the thread name for all tests.
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.
Ah, makes sense. A comment explaining that would have avoided some surprise and confusion here. :)
rust-lang/rust#121666 caused regression on hexagon linux-musl: ``` ld.lld: error: undefined symbol: pthread_getname_np ```
rust-lang/rust#121666 caused regression on hexagon linux-musl: ``` ld.lld: error: undefined symbol: pthread_getname_np ```
This reverts rust-lang#121666 due to rust-lang#123495
…ngjubilee Revert "Use OS thread name by default" This reverts rust-lang#121666 (Use the OS thread name by default if `THREAD_INFO` has not been initialized) due to rust-lang#123495 (Thread names are not always valid UTF-8). It's not a direct revert because there have been other changes since that PR.
…ngjubilee Revert "Use OS thread name by default" This reverts rust-lang#121666 (Use the OS thread name by default if `THREAD_INFO` has not been initialized) due to rust-lang#123495 (Thread names are not always valid UTF-8). It's not a direct revert because there have been other changes since that PR.
Rollup merge of rust-lang#123505 - ChrisDenton:revert-121666, r=workingjubilee Revert "Use OS thread name by default" This reverts rust-lang#121666 (Use the OS thread name by default if `THREAD_INFO` has not been initialized) due to rust-lang#123495 (Thread names are not always valid UTF-8). It's not a direct revert because there have been other changes since that PR.
This reverts rust-lang#121666 due to rust-lang#123495 This has already been done on master but beta needs something that will backport cleanly.
This reverts rust-lang#121666 due to rust-lang#123495 This has already been done on master but beta needs something that will backport cleanly. (cherry picked from commit 081ad85)
Currently if
THREAD_INFO
hasn't been initialized then the name will be set toNone
. This PR changes it to use the OS thread name by default. This mostly affects foreign threads at the moment but we could expand this to make more use of the OS thread name in the future.Note: I've only implemented
Thread::get_name
for windows, linux and macos (and macos adjacent) targets. The rest just returnNone
.