This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/17468] New: Java garbage collector miscompiled at -O1 and higher
- From: "Hans dot Boehm at hp dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Sep 2004 20:55:03 -0000
- Subject: [Bug c/17468] New: Java garbage collector miscompiled at -O1 and higher
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The (ancient) GC_descr_obj_sz() function in boehm-gc/typd_mlc.c is miscompiled
by gcc4.0 20040913. This was also true for the version from two weeks before
that. This usually causes "make check" in boehm-gc to fail. However this
function is not normally used by the gcj runtime.
I distilled this down to the self-contained example which is appended. Some
quick attempts to simplify this further by removing switch cases failed.
It is fairly easy to trace through the assembly code for the LEAF_TAG (=1)
case, and see that there is a problem. For example, the multiplication never
happens.
I haven't had a chence to check this on other platforms. It may be a generic
issue.
-fno-strict-alias has no effect, and I don't see how it could.
Hans
/* Array descriptors. GC_array_mark_proc understands these. */
/* We may eventually need to add provisions for headers and */
/* trailers. Hence we provide for tree structured descriptors, */
/* though we don't really use them currently. */
typedef union ComplexDescriptor {
struct LeafDescriptor { /* Describes simple array */
unsigned long ld_tag;
# define LEAF_TAG 1
unsigned long ld_size; /* bytes per element */
/* multiple of ALIGNMENT */
unsigned long ld_nelements; /* Number of elements. */
unsigned long ld_descriptor; /* A simple length, bitmap, */
/* or procedure descriptor. */
} ld;
struct ComplexArrayDescriptor {
unsigned long ad_tag;
# define ARRAY_TAG 2
unsigned long ad_nelements;
union ComplexDescriptor * ad_element_descr;
} ad;
struct SequenceDescriptor {
unsigned long sd_tag;
# define SEQUENCE_TAG 3
union ComplexDescriptor * sd_first;
union ComplexDescriptor * sd_second;
} sd;
} complex_descriptor;
#define TAG ld.ld_tag
/* Return the size of the object described by d. It would be faster to */
/* store this directly, or to compute it as part of */
/* GC_push_complex_descriptor, but hopefully it doesn't matter. */
unsigned long GC_descr_obj_size(d)
register complex_descriptor *d;
{
switch(d -> TAG) {
case LEAF_TAG:
return(d -> ld.ld_nelements * d -> ld.ld_size);
case ARRAY_TAG:
return(d -> ad.ad_nelements
* GC_descr_obj_size(d -> ad.ad_element_descr));
case SEQUENCE_TAG:
return(GC_descr_obj_size(d -> sd.sd_first)
+ GC_descr_obj_size(d -> sd.sd_second));
default:
return 17;
/*NOTREACHED*/ return 0; /*NOTREACHED*/
}
}
int main()
{
complex_descriptor d;
d.ld.ld_tag = 1;
d.ld.ld_size = 2;
d.ld.ld_nelements = 3;
if (GC_descr_obj_size(&d) != 6) write(2, "wrong answer\n", 13);
return 0;
}
--
Summary: Java garbage collector miscompiled at -O1 and higher
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: Hans dot Boehm at hp dot com
CC: gcc-bugs at gcc dot gnu dot org,rth at redhat dot com
GCC build triplet: ia64-unknown-linux
GCC host triplet: ia64-unknown-linux
GCC target triplet: ia64-unknown-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17468