[Gc] experimental/gc7.0alpha1.tar.gz

Ben Hutchings ben.hutchings at businesswebsoftware.com
Tue Nov 23 04:46:18 PST 2004


Hans Boehm wrote:
> I put gc7.0alpha1.tar.gz on the web site.
> 
> This release is only for people working on additions to the GC,
> etc.  This release is BROKEN ON MOST PLATFORMS.  It superficially
> appears to work on Linux/X86 and Linux/IA64.  It ran not too long
> ago on Cygwin.  It probably works on nothing else.  It currently
> builds only with the old "make test" (Makefile.direct) approach.

There's a bug in GC_generic_malloc_inner: the variable "lg" is not 
initialised in the large object case, randomising GC_bytes_allocd.  I've 
attached a patch that I think fixes this.

I've attached a second patch that makes the GC work on Win32/x86, to the 
extent of passing the tests.  The makefiles for Windows still need to be 
changed to add the atomic_ops directory to the header search path; I 
haven't done that because we build from VC++ project files instead.

Ben.
-------------- next part --------------
diff -ur gc7.0alpha1p1/malloc.c gc7.0alpha1/malloc.c
--- gc7.0alpha1p1/malloc.c	Wed Nov  3 19:41:34 2004
+++ gc7.0alpha1/malloc.c	Tue Nov 23 12:22:37 2004
@@ -99,14 +99,12 @@
 /* hold lock:					*/
 void * GC_generic_malloc_inner(size_t lb, int k)
 {
-size_t lg;
 void *op;
-void **opp;
 
     if(SMALL_OBJ(lb)) {
         register struct obj_kind * kind = GC_obj_kinds + k;
-	lg = GC_size_map[lb];
-	opp = &(kind -> ok_freelist[lg]);
+	size_t lg = GC_size_map[lb];
+	void ** opp = &(kind -> ok_freelist[lg]);
         if( (op = *opp) == 0 ) {
 	    if (GC_size_map[lb] == 0) {
 	      if (!GC_is_initialized)  GC_init_inner();
@@ -121,10 +119,11 @@
         }
         *opp = obj_link(op);
         obj_link(op) = 0;
+        GC_bytes_allocd += GRANULES_TO_BYTES(lg);
     } else {
 	op = (ptr_t)GC_alloc_large_and_clear(ADD_SLOP(lb), k, 0);
+	GC_bytes_allocd += lb;
     }
-    GC_bytes_allocd += GRANULES_TO_BYTES(lg);
     
 out:
     return op;
-------------- next part --------------
diff -ur gc7.0alpha1p1/include/private/gc_locks.h gc7.0alpha1/include/private/gc_locks.h
--- gc7.0alpha1p1/include/private/gc_locks.h	Tue Nov  9 05:47:16 2004
+++ gc7.0alpha1/include/private/gc_locks.h	Tue Nov 23 12:17:33 2004
@@ -205,7 +205,7 @@
 # endif /* !THREADS */
 
 #if defined(UNCOND_LOCK) && !defined(LOCK) 
-     extern GC_bool GC_need_to_lock;
+     GC_API GC_bool GC_need_to_lock;
      		/* At least two thread running; need to lock.	*/
 #    define LOCK() if (GC_need_to_lock) { UNCOND_LOCK(); }
 #    define UNLOCK() if (GC_need_to_lock) { UNCOND_UNLOCK(); }
diff -ur gc7.0alpha1p1/misc.c gc7.0alpha1/misc.c
--- gc7.0alpha1p1/misc.c	Thu Nov  4 22:40:26 2004
+++ gc7.0alpha1/misc.c	Tue Nov 23 12:02:42 2004
@@ -941,6 +941,9 @@
 #endif
 
 #define BUFSZ 1024
+#ifdef _MSC_VER
+# define vsnprintf _vsnprintf
+#endif
 /* A version of printf that is unlikely to call malloc, and is thus safer */
 /* to call from the collector in case malloc has been bound to GC_malloc. */
 /* Floating point arguments ans formats should be avoided, since fp	  */
diff -ur gc7.0alpha1p1/win32_threads.c gc7.0alpha1/win32_threads.c
--- gc7.0alpha1p1/win32_threads.c	Tue Nov  9 05:47:08 2004
+++ gc7.0alpha1/win32_threads.c	Tue Nov 23 12:18:24 2004
@@ -37,7 +37,7 @@
 GC_bool GC_thr_initialized = FALSE;
 
 #ifdef GC_DLL
-  GC_bool GC_need_to_lock = TRUE;
+  GC_API GC_bool GC_need_to_lock = TRUE;
   	/* Cannot intercept thread creation.	*/
 #else
   GC_bool GC_need_to_lock = FALSE;


More information about the Gc mailing list