This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libgomp/45351] many unaligned accesses in libgomp tests


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45351

--- Comment #3 from ro at CeBiTec dot Uni-Bielefeld.DE <ro at CeBiTec dot Uni-Bielefeld.DE> 2011-07-19 13:57:43 UTC ---
I see what's happening now: the unaligned access is happending inside
librt (sem_wait), with uac p noprint nofix sigbus:

Program received signal SIGBUS, Bus error.
[Switching to Thread 1]
0x000003ff81086c98 in sem_init () from /usr/shlib/librt.so
(gdb) Erroneous arithmetic operation.
(gdb) where
#0  0x000003ff81086c98 in sem_init () from /usr/shlib/librt.so
#1  0x000003ffbffefdec in gomp_sem_init (sem=0x3ffbfff02a0, value=536854016)
    at /vol/gcc/src/hg/trunk/local/libgomp/config/posix/sem.h:72
#2  0x000003ffbfff02a0 in gomp_init_task (task=0x14002bf00, parent_task=0x0, 
    prev_icv=0x3ffffff0020) at /vol/gcc/src/hg/trunk/local/libgomp/task.c:45
#3  0x000003ffbfff1eb4 in gomp_team_start (fn=0x11fffe300, data=0x11fffe310, 
    nthreads=536863560, team=0x11fffe358)
    at /vol/gcc/src/hg/trunk/local/libgomp/team.c:292
#4  0x000003ffbffef148 in GOMP_parallel_start (
    fn=0x120002db4 <sub1._omp_fn.0>, data=0x11fffbfd0, num_threads=1)
    at /vol/gcc/src/hg/trunk/local/libgomp/parallel.c:108
#5  0x0000000120002cfc in sub1 (n=2)
    at
/vol/gcc/src/hg/trunk/local/libgomp/testsuite/libgomp.c/appendix-a/a.15.1.c:30
#6  0x0000000120002d68 in main ()
    at
/vol/gcc/src/hg/trunk/local/libgomp/testsuite/libgomp.c/appendix-a/a.15.1.c:40

The actual unaligned access is one insn before:

(gdb) x/i 0x3ff81086c94
   0x3ff81086c94 <sem_init+308>:    stl    zero,0(s0)
(gdb) p/x $s0
$17 = 0x14002bf5e

Unaligned access pid=391884 <a.15.1.exe> va=0x14002bf5e pc=0x3ff81086c94
ra=0x3ff81086bf4 inst=0xb3e90000

And indeed *s0 isn't 4-byte aligned, as required by the stl insn.

I could trace this as follows:

* gomp_sem_t is sem_t (config/posix/sem.h)

* sem_t is psx4_key_t (from <semaphore.h>)

* psx4_key_t is defined in <psx4_nspace_ts.h>:

typedef unsigned short psx4_key_version_t;
typedef unsigned short psx4_key_index_t;

typedef struct psx4_key 
    {
    psx4_key_index_t index;    /* Index of entry */
    psx4_key_version_t version;    /* Version number of key */
    } psx4_key_t;

Looking at the Tru64 UNIX V5.1 sources, I find (in
src/usr/ccs/lib/librt/psx4_csem.c (sem_init)):

int
sem_init(sem_t *sem, int pshared, unsigned int value)
[...]
  *(int *)sem = 0;

i.e. the code assumes int (4-byte) alignment, but only gets short
(2-byte) alignment instead.

An appropriate attribute should fix this.  Don't know how best to fit
this into libgomp.

    Rainer


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