Use the OS thread name by default if THREAD_INFO has not been initialized#121666
Merged
bors merged 3 commits intorust-lang:masterfrom Mar 2, 2024
Merged
Use the OS thread name by default if THREAD_INFO has not been initialized#121666bors merged 3 commits intorust-lang:masterfrom
THREAD_INFO has not been initialized#121666bors merged 3 commits intorust-lang:masterfrom
Conversation
THREAD_INFO has not been initialized
ollie27
reviewed
Feb 27, 2024
9b7e102 to
f3546a2
Compare
f3546a2 to
c84ba23
Compare
cuviper
reviewed
Mar 1, 2024
Member
|
@bors r+ |
Collaborator
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Mar 2, 2024
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`.
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Mar 2, 2024
…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
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Mar 2, 2024
…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
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Mar 2, 2024
…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
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Mar 2, 2024
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`.
RalfJung
reviewed
Mar 3, 2024
| Thread::set_name(name); | ||
| assert_eq!(name, Thread::get_name().unwrap().as_c_str()); | ||
| }); | ||
| handler.join().unwrap(); |
Member
There was a problem hiding this comment.
Is there a particular reason why this test runs in a new thread, rather than the main thread?
Member
Author
There was a problem hiding this comment.
I was worried about affecting the thread name for all tests.
Member
There was a problem hiding this comment.
Ah, makes sense. A comment explaining that would have avoided some surprise and confusion here. :)
taiki-e
added a commit
to taiki-e/rust-cross-toolchain
that referenced
this pull request
Mar 3, 2024
rust-lang/rust#121666 caused regression on hexagon linux-musl: ``` ld.lld: error: undefined symbol: pthread_getname_np ```
taiki-e
added a commit
to taiki-e/atomic-maybe-uninit
that referenced
this pull request
Mar 3, 2024
rust-lang/rust#121666 caused regression on hexagon linux-musl: ``` ld.lld: error: undefined symbol: pthread_getname_np ```
ChrisDenton
added a commit
to ChrisDenton/rust
that referenced
this pull request
Apr 5, 2024
This reverts rust-lang#121666 due to rust-lang#123495
workingjubilee
added a commit
to workingjubilee/rustc
that referenced
this pull request
Apr 5, 2024
…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.
GuillaumeGomez
added a commit
to GuillaumeGomez/rust
that referenced
this pull request
Apr 5, 2024
…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.
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Apr 6, 2024
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.
ChrisDenton
added a commit
to ChrisDenton/rust
that referenced
this pull request
Apr 6, 2024
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.
cuviper
pushed a commit
to cuviper/rust
that referenced
this pull request
Apr 11, 2024
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently if
THREAD_INFOhasn'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_namefor windows, linux and macos (and macos adjacent) targets. The rest just returnNone.