gcc-3.4.2 or libpthread bug?
Peter Seiderer
ps.report@gmx.net
Mon Sep 13 14:06:00 GMT 2004
Hello,
the following attached testprogramm gives a SIGSEGV when compiled
with gcc-3.4.2 and '-march=pentium4 -O2' on my Linux box (Suse-8.2),
I think because of a misaligned movapd.
Is it a gcc or a libpthread bug?
Thanks for your help in advance,
Peter
--- begin test.cpp ---
#include <pthread.h>
double sin(double x);
double cos(double x);
typedef struct {
double x, y, z;
} DVECTOR;
typedef struct {
DVECTOR m[4];
} DMATRIX;
void
geo_lla_xyz(DVECTOR *lla, DVECTOR *geo)
{
lla->x = geo->y;
lla->y = geo->z;
lla->z = 1.0;
}
void
create_geo_to_topo(DMATRIX *xfp, double lat, double lon)
{
double cos_lat;
{
double sin_lon, cos_lon, sin_lat;
sin_lon = sin(lon);
cos_lon = cos(lon);
sin_lat = sin(lat);
cos_lat = cos(lat);
xfp->m[0].x = -sin_lon;
xfp->m[1].x = cos_lon;
xfp->m[2].x = 0.0;
xfp->m[0].y = -cos_lon * sin_lat;
xfp->m[1].y = -sin_lon * sin_lat;
xfp->m[2].y = cos_lat;
xfp->m[0].z = cos_lon * cos_lat;
xfp->m[1].z = sin_lon * cos_lat;
xfp->m[2].z = sin_lat;
{
DVECTOR geo;
DVECTOR lla;
lla.x = lat;
lla.y = lon;
lla.z = 0.0;
geo_lla_xyz( &lla, &geo);
xfp->m[3].x = -geo.x;
}
}
}
void *thread(void *arg) {
DMATRIX xfp;
create_geo_to_topo(&xfp, 1.0, 1.0);
return 0;
}
int main(int argc, char *argv[]) {
int i;
pthread_t threads[10];
for(i = 0; i < 10 ; i++) {
pthread_create(&threads[i], 0, thread, 0);
}
for(i = 0; i < 10 ; i++) {
pthread_join(threads[i], 0);
}
return 0;
}
--- end test.cpp ---
/opt/gcc-3.4.2/bin/g++ -Wall -march=pentium4 -O2 -g -pthread test.cpp -lm
LD_LIBRARY_PATH=/opt/gcc-3.4.2/lib gdb ./a.out
GNU gdb 6.1
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...Using host libthread_db
library "/lib/libthread_db.so.1".
(gdb) run
Starting program: /home/seiderer/test/gcc_bug_14776/a.out
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 6325)]
[New Thread 32769 (LWP 6327)]
[New Thread 16386 (LWP 6328)]
[New Thread 32771 (LWP 6329)]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16386 (LWP 6328)]
create_geo_to_topo (xfp=0xbf7ffa6c, lat=1, lon=1) at test.cpp:35
35 xfp->m[0].x = -sin_lon;
(gdb) info reg
eax 0xbf7ff9fc -1082131972
ecx 0x4029bd60 1076477280
edx 0x6 6
ebx 0xbf7ffa6c -1082131860
esp 0xbf7ff9bc 0xbf7ff9bc
ebp 0xbf7ffa44 0xbf7ffa44
esi 0xbf7ffbe0 -1082131488
edi 0x0 0
eip 0x8048642 0x8048642
eflags 0x10246 66118
cs 0x23 35
ss 0x2b 43
ds 0x2b 43
es 0x2b 43
fs 0x0 0
gs 0x0 0
(gdb) disassemble
Dump of assembler code for function _Z18create_geo_to_topoP7DMATRIXdd:
0x08048590 <_Z18create_geo_to_topoP7DMATRIXdd+0>: push %ebp
0x08048591 <_Z18create_geo_to_topoP7DMATRIXdd+1>: mov %esp,%ebp
0x08048593 <_Z18create_geo_to_topoP7DMATRIXdd+3>: push %ebx
0x08048594 <_Z18create_geo_to_topoP7DMATRIXdd+4>: sub $0x84,%esp
0x0804859a <_Z18create_geo_to_topoP7DMATRIXdd+10>: fldl 0x14(%ebp)
0x0804859d <_Z18create_geo_to_topoP7DMATRIXdd+13>: mov
0x8(%ebp),%ebx
0x080485a0 <_Z18create_geo_to_topoP7DMATRIXdd+16>: fstpl (%esp)
0x080485a3 <_Z18create_geo_to_topoP7DMATRIXdd+19>: call 0x80484a8
<sin>
0x080485a8 <_Z18create_geo_to_topoP7DMATRIXdd+24>: fldl 0x14(%ebp)
0x080485ab <_Z18create_geo_to_topoP7DMATRIXdd+27>: fstpl (%esp)
0x080485ae <_Z18create_geo_to_topoP7DMATRIXdd+30>: fstpl
0xffffffb0(%ebp)
0x080485b1 <_Z18create_geo_to_topoP7DMATRIXdd+33>: call 0x8048468
<cos>
0x080485b6 <_Z18create_geo_to_topoP7DMATRIXdd+38>: fstpl
0xffffffa8(%ebp)
0x080485b9 <_Z18create_geo_to_topoP7DMATRIXdd+41>: fldl 0xc(%ebp)
0x080485bc <_Z18create_geo_to_topoP7DMATRIXdd+44>: fstpl (%esp)
0x080485bf <_Z18create_geo_to_topoP7DMATRIXdd+47>: call 0x80484a8
<sin>
0x080485c4 <_Z18create_geo_to_topoP7DMATRIXdd+52>: fldl 0xc(%ebp)
0x080485c7 <_Z18create_geo_to_topoP7DMATRIXdd+55>: fstpl (%esp)
0x080485ca <_Z18create_geo_to_topoP7DMATRIXdd+58>: fstpl
0xffffffa0(%ebp)
0x080485cd <_Z18create_geo_to_topoP7DMATRIXdd+61>: call 0x8048468
<cos>
0x080485d2 <_Z18create_geo_to_topoP7DMATRIXdd+66>: fldl
0xffffffa8(%ebp)
0x080485d5 <_Z18create_geo_to_topoP7DMATRIXdd+69>: fldl
0xffffffb0(%ebp)
0x080485d8 <_Z18create_geo_to_topoP7DMATRIXdd+72>: fxch %st(1)
0x080485da <_Z18create_geo_to_topoP7DMATRIXdd+74>: fstl 0x18(%ebx)
0x080485dd <_Z18create_geo_to_topoP7DMATRIXdd+77>: fchs
0x080485df <_Z18create_geo_to_topoP7DMATRIXdd+79>: fxch %st(1)
0x080485e1 <_Z18create_geo_to_topoP7DMATRIXdd+81>: fchs
0x080485e3 <_Z18create_geo_to_topoP7DMATRIXdd+83>: fxch %st(1)
0x080485e5 <_Z18create_geo_to_topoP7DMATRIXdd+85>: fmull
0xffffffa0(%ebp)
0x080485e8 <_Z18create_geo_to_topoP7DMATRIXdd+88>: fxch %st(1)
0x080485ea <_Z18create_geo_to_topoP7DMATRIXdd+90>: fstl (%ebx)
0x080485ec <_Z18create_geo_to_topoP7DMATRIXdd+92>: fxch %st(2)
0x080485ee <_Z18create_geo_to_topoP7DMATRIXdd+94>: fstl 0x38(%ebx)
0x080485f1 <_Z18create_geo_to_topoP7DMATRIXdd+97>: fxch %st(1)
0x080485f3 <_Z18create_geo_to_topoP7DMATRIXdd+99>: fstpl 0x8(%ebx)
0x080485f6 <_Z18create_geo_to_topoP7DMATRIXdd+102>: fldl
0xffffffa8(%ebp)
0x080485f9 <_Z18create_geo_to_topoP7DMATRIXdd+105>: fldz
0x080485fb <_Z18create_geo_to_topoP7DMATRIXdd+107>: fxch %st(1)
0x080485fd <_Z18create_geo_to_topoP7DMATRIXdd+109>: fmul %st(2),%st
0x080485ff <_Z18create_geo_to_topoP7DMATRIXdd+111>: fxch %st(3)
0x08048601 <_Z18create_geo_to_topoP7DMATRIXdd+113>: fmull
0xffffffa0(%ebp)
0x08048604 <_Z18create_geo_to_topoP7DMATRIXdd+116>: fxch %st(3)
0x08048606 <_Z18create_geo_to_topoP7DMATRIXdd+118>: lea
0xffffffd8(%ebp),%eax
0x08048609 <_Z18create_geo_to_topoP7DMATRIXdd+121>: fstpl 0x10(%ebx)
0x0804860c <_Z18create_geo_to_topoP7DMATRIXdd+124>: fldl
0xffffffb0(%ebp)
0x0804860f <_Z18create_geo_to_topoP7DMATRIXdd+127>: fxch %st(1)
0x08048611 <_Z18create_geo_to_topoP7DMATRIXdd+129>: fstl 0x30(%ebx)
0x08048614 <_Z18create_geo_to_topoP7DMATRIXdd+132>: fxch %st(1)
0x08048616 <_Z18create_geo_to_topoP7DMATRIXdd+134>: fmulp %st,%st(2)
0x08048618 <_Z18create_geo_to_topoP7DMATRIXdd+136>: fldl
0xffffffa0(%ebp)
0x0804861b <_Z18create_geo_to_topoP7DMATRIXdd+139>: fxch %st(3)
0x0804861d <_Z18create_geo_to_topoP7DMATRIXdd+141>: fstpl 0x20(%ebx)
0x08048620 <_Z18create_geo_to_topoP7DMATRIXdd+144>: fxch %st(1)
0x08048622 <_Z18create_geo_to_topoP7DMATRIXdd+146>: fstpl 0x28(%ebx)
0x08048625 <_Z18create_geo_to_topoP7DMATRIXdd+149>: fxch %st(1)
0x08048627 <_Z18create_geo_to_topoP7DMATRIXdd+151>: fstpl 0x40(%ebx)
0x0804862a <_Z18create_geo_to_topoP7DMATRIXdd+154>: fldl 0xc(%ebp)
0x0804862d <_Z18create_geo_to_topoP7DMATRIXdd+157>: fldl 0x14(%ebp)
0x08048630 <_Z18create_geo_to_topoP7DMATRIXdd+160>: mov
%eax,0x4(%esp)
0x08048634 <_Z18create_geo_to_topoP7DMATRIXdd+164>: movsd
0x80487c0,%xmm0
0x0804863c <_Z18create_geo_to_topoP7DMATRIXdd+172>: lea
0xffffffb8(%ebp),%eax
0x0804863f <_Z18create_geo_to_topoP7DMATRIXdd+175>: fstpl
0xffffffc0(%ebp)
0x08048642 <_Z18create_geo_to_topoP7DMATRIXdd+178>: movapd
%xmm0,0xffffff88(%ebp)
0x08048647 <_Z18create_geo_to_topoP7DMATRIXdd+183>: fstpl
0xffffffb8(%ebp)
0x0804864a <_Z18create_geo_to_topoP7DMATRIXdd+186>: fstpl
0xffffffc8(%ebp)
0x0804864d <_Z18create_geo_to_topoP7DMATRIXdd+189>: mov %eax,(%esp)
0x08048650 <_Z18create_geo_to_topoP7DMATRIXdd+192>: call 0x8048574
<_Z11geo_lla_xyzP7DVECTORS0_>
0x08048655 <_Z18create_geo_to_topoP7DMATRIXdd+197>: fldl
0xffffffd8(%ebp)
0x08048658 <_Z18create_geo_to_topoP7DMATRIXdd+200>: fchs
0x0804865a <_Z18create_geo_to_topoP7DMATRIXdd+202>: fstpl 0x48(%ebx)
0x0804865d <_Z18create_geo_to_topoP7DMATRIXdd+205>: add $0x84,%esp
0x08048663 <_Z18create_geo_to_topoP7DMATRIXdd+211>: pop %ebx
0x08048664 <_Z18create_geo_to_topoP7DMATRIXdd+212>: pop %ebp
0x08048665 <_Z18create_geo_to_topoP7DMATRIXdd+213>: ret
End of assembler dump.
--
Supergünstige DSL-Tarife + WLAN-Router für 0,- EUR*
Jetzt zu GMX wechseln und sparen http://www.gmx.net/de/go/dsl
More information about the Gcc
mailing list