This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
DB 3.0.55, memset() and overoptimizacion
- To: db at sleepycat dot com, gcc at gcc dot gnu dot org
- Subject: DB 3.0.55, memset() and overoptimizacion
- From: Jesus Cea Avion <jcea at argo dot es>
- Date: Wed, 01 Dec 1999 05:06:09 +0100
- Organization: Argo Redes y Servicios Telematicos, S.A. - http://www.argo.es/
I was just trying to use the new DB 3.0.55, but my source core dumps
consistently. I found the bug inside DB library, in "memset()" usage.
The problem seems to be a over-optimization in the new GCC 2.95.2 (not
checked using other compilers), UltraSparc (Sun Microsystems). When the
pointer in "memset" points to a struct and the counter is a compiler
time constant, GCC assumes 64bits alignment and emits "std" (store
double: 64 bits) assembler instructions. But, at least in UltraSparc I,
"std" needs to be aligned in 64 bit boundaries or you are dead.
DB 3.0.55 only garantees a sizeof(size_t) (tipically 32 bits) alignment.
Two posible patches:
a) Align structs in memory in 64bits boundaries.
b) Defeat the "memset()" GCC trick usign a casting to (char *), for
example. (not checked)
c) Perhaps next GCC release should be a bit less agressive...
Here you have a fast&dirty patch (works for me) using the first
approach:
>>>>>
diff -c -r1.1.1.1 -r1.2
*** env/db_salloc.c 1999/10/19 21:22:12 1.1.1.1
--- env/db_salloc.c 1999/12/01 03:40:49 1.2
***************
*** 94,101 ****
*/
++len;
#endif
! align = align <= sizeof(size_t) ?
! sizeof(size_t) : ALIGN(align, sizeof(size_t));
/* Walk the list, looking for a slot. */
for (elp = SH_LIST_FIRST((struct __head *)p, __data);
--- 94,101 ----
*/
++len;
#endif
! align = align <= (2*sizeof(size_t)) ?
! (2*sizeof(size_t)) : ALIGN(align, (2*sizeof(size_t)));
/* Walk the list, looking for a slot. */
for (elp = SH_LIST_FIRST((struct __head *)p, __data);
<<<<<
God, 5:10 AM!. Time to rest...
--
Jesus Cea Avion _/_/ _/_/_/ _/_/_/
jcea@argo.es http://www.argo.es/~jcea/ _/_/ _/_/ _/_/ _/_/ _/_/
_/_/ _/_/ _/_/_/_/_/
PGP Key Available at KeyServ _/_/ _/_/ _/_/ _/_/ _/_/
"Things are not so easy" _/_/ _/_/ _/_/ _/_/ _/_/ _/_/
"My name is Dump, Core Dump" _/_/_/ _/_/_/ _/_/ _/_/
"El amor es poner tu felicidad en la felicidad de otro" - Leibniz