[Gc] Possible problem in `GC_is_valid_displacement'?

Boehm, Hans hans_boehm@hp.com
Mon, 12 May 2003 17:31:32 -0700


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C318E7.00DE3360
Content-Type: text/plain;
	charset="iso-8859-1"

I agree.  This is a bug in GC_is_valid_displacement.  Thanks for reporting it.

Please try the attached patch.  (The second change is substantive, the first is a minor cleanup.)

Hans

> -----Original Message-----
> From: Emmanuel Stapf [ES] [mailto:manus@eiffel.com]
> Sent: Saturday, May 10, 2003 7:41 PM
> To: gc@napali.hpl.hp.com
> Subject: [Gc] Possible problem in `GC_is_valid_displacement'?
> 
> 
> Hi,
> 
> I've been using `GC_is_valid_displacement' and found that the 
> following code fails
> on Win32 with 6.1 and GC_WIN32_THREADS and of course 
> ALL_INTERIOR_POINTERs
> disabled.
> 
> {
> 	char * toto = NULL;
> 	GC_register_displacement(8);
> 	toto = GC_malloc (1248);
> 	GC_is_valid_displacement(toto);
> 	GC_is_valid_displacement(toto + 8);
> }
> 
> It fails on both call to `GC_is_valid_displacement'. The 
> bizarre thing is that it
> does not do it on all blocks, but it does it when I allocate 
> 1248 bytes.
> 
> Although the test fails, commenting it out and my application 
> just works fine.
> 
> Regards,
> Manu
> 
> 
> _______________________________________________
> Gc mailing list
> Gc@linux.hpl.hp.com
> http://linux.hpl.hp.com/cgi-bin/mailman/listinfo/gc
> 


------_=_NextPart_000_01C318E7.00DE3360
Content-Type: application/octet-stream;
	name="ptr_chck.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="ptr_chck.diff"

--- ptr_chck.c.old	2003-05-12 17:29:01.000000000 -0700=0A=
+++ ptr_chck.c	2003-05-12 17:29:55.000000000 -0700=0A=
@@ -79,7 +79,7 @@=0A=
 	return(p);=0A=
     }=0A=
     sz =3D WORDS_TO_BYTES(hhdr -> hb_sz);=0A=
-    if (sz > WORDS_TO_BYTES(MAXOBJSZ)) {=0A=
+    if (sz > MAXOBJBYTES) {=0A=
       base =3D (ptr_t)HBLKPTR(p);=0A=
       limit =3D base + sz;=0A=
       if ((ptr_t)p >=3D limit) {=0A=
@@ -165,7 +165,7 @@=0A=
     pdispl =3D HBLKDISPL(p);=0A=
     map_entry =3D MAP_ENTRY((hhdr -> hb_map), pdispl);=0A=
     if (map_entry =3D=3D OBJ_INVALID=0A=
-    	|| sz > MAXOBJSZ && (ptr_t)p >=3D (ptr_t)h + sz) {=0A=
+    	|| sz > MAXOBJBYTES && (ptr_t)p >=3D (ptr_t)h + sz) {=0A=
     	goto fail;=0A=
     }=0A=
     return(p);=0A=

------_=_NextPart_000_01C318E7.00DE3360--