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

provide thread name to OS for Solarish systems #62302

Closed
jlevon opened this issue Jul 2, 2019 · 0 comments · Fixed by #62309
Closed

provide thread name to OS for Solarish systems #62302

jlevon opened this issue Jul 2, 2019 · 0 comments · Fixed by #62309
Labels
O-solaris Operating system: Solaris T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@jlevon
Copy link
Contributor

jlevon commented Jul 2, 2019

Both Solaris 11 and recentish Illumos provide the same pthread_setname_np() API.
While libstd can't presume the existence of the symbol, it seems like using weak! works sufficiently to set the thread name when necessary.

While the implementation is different, the API is basically the same for the purposes of set_name().

The Linux implementation of set_name() will silently truncate the thread name, while the NetBSD (and I think, FreeBSD) will return an error. Since the std::thread implementation has no way to return an error right now, we need to choose between silent truncation or silent failure. Given the risk of mis-identification in truncation (it's likely that the unique part of the name is the end), it seems best to fail silently instead. On the plus side, this API has significantly more space than Linux's.

@jonas-schievink jonas-schievink added O-solaris Operating system: Solaris T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Jul 2, 2019
bors added a commit that referenced this issue Aug 2, 2019
provide thread name to OS for Solarish systems

Fixes #62302

Passes a Linux bootstrap build. python x.py test src/tools/tidy happy.
I tested this with a small test binary that spawns a few threads, and verified
that:

 - on an illumos system lacking the libc function, the binary runs but no OS-level
    thread names are set
 - on an illumos system with the feature, the binary runs, and the thread names are
    visible and correct under tools like MDB, pstack, core dump, etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-solaris Operating system: Solaris T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants