From ccbcc0aeed1b69d5eaedd768f3d29cebfb42964d Mon Sep 17 00:00:00 2001 From: Michael Kerrisk Date: Tue, 5 May 2015 21:11:59 +0200 Subject: [PATCH] pthreads.7: Using thread IDs whose lifetime has expired gives undefined behavior See https://bugzilla.kernel.org/show_bug.cgi?id=53061 Reported-by: KOSAKI Motohiro Signed-off-by: Michael Kerrisk --- man7/pthreads.7 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/man7/pthreads.7 b/man7/pthreads.7 index 98eb86187..906b5a08c 100644 --- a/man7/pthreads.7 +++ b/man7/pthreads.7 @@ -127,8 +127,10 @@ Thread IDs are guaranteed to be unique only within a process. that ID by definition refers to a thread in the same process as the caller.) -A thread ID may be reused after a terminated thread has been joined, +The system may reuse a thread ID after a terminated thread has been joined, or a detached thread has terminated. +POSIX says: "If an application attempts to use a thread ID whose +lifetime has ended, the behavior is undefined." .SS Thread-safe functions A thread-safe function is one that can be safely (i.e., it will deliver the same results regardless of whether it is)