This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

linuxthreads/spinlock.c bug


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]