From owner-freebsd-threads@FreeBSD.ORG Wed Jun 4 05:38: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 7492C37B401 for ; Wed, 4 Jun 2003 05:38:48 -0700 (PDT) Received: from matou.sibbald.com (matou.sibbald.com [195.202.201.48]) by mx1.FreeBSD.org (Postfix) with ESMTP id DD3C743FA3 for ; Wed, 4 Jun 2003 05:38:46 -0700 (PDT) (envelope-from kern@sibbald.com) Received: from [192.168.68.112] (rufus [192.168.68.112]) by matou.sibbald.com (8.11.6/8.11.6) with ESMTP id h54Ccjv14191 for ; Wed, 4 Jun 2003 14:38:45 +0200 From: Kern Sibbald To: freebsd-threads@freebsd.org Content-Type: multipart/mixed; boundary="=-3yPEbVH5Pe+LqlZXsJlK" Organization: Message-Id: <1054730325.13630.456.camel@rufus> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.4 Date: 04 Jun 2003 14:38:45 +0200 X-Content-Filtered-By: Mailman/MimeDel 2.1.1 Subject: 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 12:38:48 -0000 --=-3yPEbVH5Pe+LqlZXsJlK Content-Type: text/plain Content-Transfer-Encoding: 7bit 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. Even if someone were to claim that this case is undefined, I would say fine, but it is rather trivial to ensure that pthread_equal() returns false unless the thread is really physically the same thread, you just need one variable in pthread_t that is incremented for each new thread, so why not do it "the right way". This bug exists in the FreeBSD implementation but not in Linux or in Solaris. I've worked around the bug so this is not a critical issue for me. I've attached a simple program that illustrates this problem. Don't hesitate to ask if you have any questions, but please be aware that I am not subscribed to the list. Best regards, Kern Switzerland --=-3yPEbVH5Pe+LqlZXsJlK--