Skip site navigation (1)Skip section navigation (2)
Date:      04 Jun 2003 14:38:45 +0200
From:      Kern Sibbald <kern@sibbald.com>
To:        freebsd-threads@freebsd.org
Subject:   FreeBSD pthread_equal "bug"
Message-ID:  <1054730325.13630.456.camel@rufus>

next in thread | raw e-mail | index | archive | help

--=-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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1054730325.13630.456.camel>