This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
linuxthreads/spinlock.c bug
- To: <drepper at redhat dot com>
- Subject: linuxthreads/spinlock.c bug
- From: Kaz Kylheku <kaz at ashi dot footprints dot net>
- Date: Wed, 17 Oct 2001 10:53:23 -0700 (PDT)
- cc: GNU C Library <libc-alpha at sourceware dot cygnus dot com>
The wait_node_alloc an wait_node_free functions are braindamaged
because they naively implement a stack using compare_and_swap.
The problem is that when you remove a node, it's possible for
the compare_and_swap to succeed even if the list has changed,
just because the head pointer is identical. E.g. suppose
you evaluate the head pointer while the list looks like this:
X -> Y -> Z -> 0
Meanwhile some other threads comes along and do:
(pop X)
Y -> Z -> 0
(pop Y)
Z -> 0
(push X)
X -> Z -> 0
So now the original thread's compare_and_swap can still succeed, due
to the match on the X, even though the list is different now.
I propose to scrap the ``optimization'' in wait_node_alloc/free and just
use malloc/free directly.