[parisc-linux] ldcw in __pthread_acquire
Alan Modra
alan@linuxcare.com.au
Fri, 15 Dec 2000 22:37:55 +1100 (EST)
On Fri, 15 Dec 2000, John Marvin wrote:
>
> I just ran into an unaligned data reference in user land. The problem is
> that the routine __pthread_acquire (in libpthread) does a ldcw, but it is
> not ensuring that the address it is operating on is 16 byte aligned (it is
> operating on the address that was passed in as the first argument). Some
> processors don't require the 16 byte alignment, but many do.
>
> I haven't looked at the source (I just found the location by disassembly),
> so I don't know what the root cause is. The actual ldcw is probably from
> an inlined function or macro, e.g. spin_lock(). My first guess would be
> that it is using the machine dependent spin_lock macro, but the procedure
> which called __pthread_acquire is passing in a structure whose lock field
> does not have the aligned(16) attribute.
>
> I don't have time to look at this right now. Any volunteers?
This isn't exactly volunteering, but I've looked at this code before.
Here's where the problem is:
glibc/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h
struct _pthread_fastlock
{
long int __status; /* "Free" or "taken" or head of waiting list */
int __spinlock; /* Used by compare_and_swap emulation. Also,
adaptive SMP lock stores spin count here. */
};
--
Linuxcare. Support for the Revolution.