From owner-freebsd-threads@FreeBSD.ORG Wed Jun 4 08:30:48 2003 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7532437B497 for ; Wed, 4 Jun 2003 08:30:48 -0700 (PDT) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7C91F43F85 for ; Wed, 4 Jun 2003 08:30:47 -0700 (PDT) (envelope-from eischen@pcnet.com) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mail.pcnet.com (8.12.8/8.12.1) with ESMTP id h54FUiNc014412; Wed, 4 Jun 2003 11:30:44 -0400 (EDT) Date: Wed, 4 Jun 2003 11:30:44 -0400 (EDT) From: Daniel Eischen To: Kern Sibbald In-Reply-To: <1054730325.13630.456.camel@rufus> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-threads@freebsd.org Subject: Re: FreeBSD pthread_equal "bug" X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jun 2003 15:30:49 -0000 On 4 Jun 2003, Kern Sibbald wrote: > Hello, > > I've run into what I consider a bug in the FreeBSD > implementation of pthreads and pthread_equal() in > particular. Basically, pthread_equal() will return > true even if it is not the same thread. This can occur > when one thread dies and another one starts. The second > thread then takes on the exact identity of the the > first thread, and pthread_equal() returns true for a > case where it is a different thread. You may argue > that the first thread is dead so its thread id is no > longer valid. True, but think about how Unix would > work if every process started up with the process > id of the last process to exit. Process id's can wrap around so it can eventually happen. This is a bug in the application; the implementation is allowed to reuse thread id's and there are enough interfaces for an application to tell when a thread terminates (pthread_join). Perhaps our use of thread id's could be changes so that they were cached at the end of the free thread list, but cacheing them at the front seems to highlight bad applications, so that's a bonus ;-) -- Dan Eischen