This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
AW: Specific Linux syscalls for glibc API
- From: "Warlich, Christof" <christof dot warlich at siemens dot com>
- To: Rich Felker <dalias at libc dot org>, "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>
- Date: Thu, 19 Nov 2015 07:21:13 +0000
- Subject: AW: Specific Linux syscalls for glibc API
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 2 dot 10 dot 1511171606330 dot 14808 at digraph dot polyomino dot org dot uk> <564C4DCA dot 3010607 at redhat dot com> <20151118163229 dot GO3818 at brightrain dot aerifal dot cx>
On 18-11-2015 14:32, Rich Felker wrote:
> It should be noted that there are some serious caveats to using tids
> directly. Unlike pthread_t, a tid is immediately freed and available
> for reuse as soon as the thread exits. This means additional
> synchronization with the target thread's exit is required to avoid
> TOCTOU races when use them.
I'm not sure if I really got your point here. While there is no doubt that
synchronization _is_ needed if a tid must never be used after it has become
invalid (due to the exit of its related thread), I don't see much of a risk
that a tid value might be reused by a newly created thread any time soon:
AFAIK, newly allocated tids are, like pids, always incremented. Thus, a
tid reuse can only happen after wrapping around.
Again, while I fully agree that synchronization might be necessary, the
overall situation w.r.t. tid reusage is not be as bad as indicated.