memset inlining assumes 8 byte alignment

Dmitri Kuznetsov Dmitri.Kuznetsov@wcom.com
Sun Jan 2 17:22:00 GMT 2000


GCC version: 2.95.2
Platform: UltraSparc
OS: Solaris 7
Options: -O -g
Software: Berkley DB 3.0.55 ( http://www.sleepycat.com )

The program generates SIGBUS when the DB evironment is being opened. The

code causing trouble is at line 996 of "env_region.c", function
__db_des_get:
    memset( rp, 0, sizeof(*rp));
It turns out the compiler inlines memset as shown in this disassemble
dump from gdb:
0xb24a0 <__db_des_get+248>:     ld  [ %fp + -20 ], %o2
0xb24a4 <__db_des_get+252>:     clr  %o0
0xb24a8 <__db_des_get+256>:     clr  %o1
0xb24ac <__db_des_get+260>:     std  %o0, [ %o2 ]
0xb24b0 <__db_des_get+264>:     std  %o0, [ %o2 + 8 ]
0xb24b4 <__db_des_get+268>:     std  %o0, [ %o2 + 0x10 ]
0xb24b8 <__db_des_get+272>:     std  %o0, [ %o2 + 0x18 ]
0xb24bc <__db_des_get+276>:     std  %o0, [ %o2 + 0x20 ]
0xb24c0 <__db_des_get+280>:     std  %o0, [ %o2 + 0x28 ]
0xb24c4 <__db_des_get+284>:     std  %o0, [ %o2 + 0x30 ]
0xb24c8 <__db_des_get+288>:     std  %o0, [ %o2 + 0x38 ]
0xb24cc <__db_des_get+292>:     std  %o0, [ %o2 + 0x40 ]
0xb24d0 <__db_des_get+296>:     std  %o0, [ %o2 + 0x48 ]
0xb24d4 <__db_des_get+300>:     std  %o0, [ %o2 + 0x50 ]
0xb24d8 <__db_des_get+304>:     std  %o0, [ %o2 + 0x58 ]

The problem is that __db_shalloc returns data aligned to MUTEX_ALIGN or
sizeof(size_t) whichever is larger, that is 4. But as far as I
understand the code above fails uless the data pointed to by "rp" is
aligned at 8 byte boundary.
I wonder if that is a correct behaviour on the platform in 32 bit mode.


Thank you,
Dmitri.




More information about the Gcc-bugs mailing list