This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug nptl/6419] New: __lll_mutex_timedlock_wait segfault on x86_64
- From: "plasmahh at gmx dot net" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 17 Apr 2008 08:41:28 -0000
- Subject: [Bug nptl/6419] New: __lll_mutex_timedlock_wait segfault on x86_64
- Reply-to: sourceware-bugzilla at sourceware dot org
Hi, I experience almost immediate crashes with the following little program
(running under various linux kernels, including 2.6.20.17, 2.6.23.:
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <errno.h>
pthread_mutex_t m;
void* foo (void* x )
{
while(1)
{
struct timespec ts;
int result = 0;
clock_gettime(CLOCK_REALTIME, &ts);
ts.tv_sec += 2;
result = pthread_mutex_timedlock(&m, &ts);
if( result )
{
printf("result = %d in %d\n",result,__LINE__);
abort();
}
result = pthread_mutex_unlock(&m);
if( result )
{
printf("result = %d in %d\n",result,__LINE__);
abort();
}
}
}
int main ()
{
pthread_t t;
int result = pthread_mutex_init(&m, 0);
if( result )
{
printf("result = %d in %d\n",result,__LINE__);
abort();
}
result = pthread_create(&t,0,&foo,0);
if( result )
{
printf("result = %d in %d\n",result,__LINE__);
abort();
}
foo(0);
}
The crash happens in ./nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S (from
glibc2.7 tarball) in line 264 at the "xchgl %eax, (%rdi)" instruction.
It looks to me that the code flow comes from the syscall in 221, then 228 jumps
to 259, 260 does not jump and then the rdi register is used. In e.g.
http://www.x86-64.org/documentation/abi.pdf I found that the rdi register is not
preserved across syscalls/function calls, as this it the case here. It looks as
if the value thats in r12 is expected here.
I have patched my version to use "xchgl %eax, (%r12)", and it now runs
smoothly, however there are two things that bother me:
1.) why did noone had the same problems yet?
2.) Is there maybe another usage of edi that could crash the same way?
Btw. I just heard from a friend that this thing runs just fine on his computer,
but he has a single core, while all of my computers are multicores or at least
have hyperthreading available.
--
Summary: __lll_mutex_timedlock_wait segfault on x86_64
Product: glibc
Version: unspecified
Status: NEW
Severity: critical
Priority: P3
Component: nptl
AssignedTo: drepper at redhat dot com
ReportedBy: plasmahh at gmx dot net
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=6419
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.