public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug nptl/27880] New: Please provide a pthread pid accessor
@ 2021-05-18  1:19 hpa at zytor dot com
  2021-05-18  5:05 ` [Bug nptl/27880] " hpa at zytor dot com
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: hpa at zytor dot com @ 2021-05-18  1:19 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=27880

            Bug ID: 27880
           Summary: Please provide a pthread pid accessor
           Product: glibc
           Version: unspecified
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: nptl
          Assignee: unassigned at sourceware dot org
          Reporter: hpa at zytor dot com
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

There is currently no way to access the kernel tid for another pthread, except
via the very cumbersome thread_db interface. The intent is good, to provide
interface isolation, but sometimes having such cross-layer interfaces (e.g.
fileno()) are at the very least serve a "harm reduction" function.

As it is, there are enough reasons access to a tid is necessary that
programmers are employing multiple unsafe techniques:

1. Calling gettid() early in the thread main function and caching that value
indefinitely;
2. Mixing pthreads and raw calls to clone();
3. Extracting or even hard-coding the offset for tid in struct pthread (almost
never using any kind of hard version tying.)

Having an interface like:

pid_t pthread_gettid_np(pthread_t thread)

... would at least allow the interface to be kept in sync with the current
libpthread, and provides a path to returning an error if no meaningful tid is
available (e.g. in the case of M:N threads, or the underlying kernel thread no
longer existing.)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2024-02-06 22:30 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-18  1:19 [Bug nptl/27880] New: Please provide a pthread pid accessor hpa at zytor dot com
2021-05-18  5:05 ` [Bug nptl/27880] " hpa at zytor dot com
2021-05-18 18:36 ` joseph at codesourcery dot com
2021-05-18 19:31 ` hpa at zytor dot com
2021-05-18 20:58 ` adhemerval.zanella at linaro dot org
2021-05-19 20:14 ` fweimer at redhat dot com
2021-05-19 20:21 ` hpa at zytor dot com
2021-05-19 20:27 ` adhemerval.zanella at linaro dot org
2021-05-19 20:31 ` hpa at zytor dot com
2021-05-19 20:49 ` fweimer at redhat dot com
2021-05-19 22:50 ` mtk.manpages at gmail dot com
2021-05-27 19:32 ` adhemerval.zanella at linaro dot org
2021-05-27 23:48 ` hpa at zytor dot com
2023-04-14  3:50 ` sam at gentoo dot org
2024-02-06 22:30 ` jkriegshauser at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).