[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elk] found bug related to GC crash



hi *,

attached a patch which fixes a bug leading to crash the garbage
collector.  in the elk-3.0 code it's apparently present, too.

the smallest type number assigned to the first defined type was by one
too small: thus handing out T_Broken_Hart (with sc gc) oder freetype
(gc-gen).

my dummy-test:

(define (crash)
	(collect)
	(crash))
(crash)

does not crash anymore.

surprisingly, alexander lechner's bug.scm doesn't crash neither on the
fixed nor the unfixed version.  was that bug.scm for elk-3.0 or
elk-3.99.6?  AFAIK some GC bugs were fixed between 3.0 and -99.6.

bests,

martin

diff -rpuN elk-trunk/src/type.c elk-trunk-new/src/type.c
--- elk-trunk/src/type.c	2004-01-28 07:36:18.000000000 -0700
+++ elk-trunk-new/src/type.c	2004-08-07 03:36:06.000000000 -0600
@@ -1,6 +1,6 @@
 /* type.c: Built-in and user-defined Scheme types.
  *
- * $Id: type.c 103 2003-09-06 11:25:29Z sam $
+ * $Id: type.c,v 1.2 2004/08/07 00:26:42 rumori Exp $
  *
  * Copyright 1990, 1991, 1992, 1993, 1994, 1995, Oliver Laumann, Berlin
  * Copyright 2002, 2003 Sam Hocevar <sam@zoy.org>, Paris
@@ -105,7 +105,13 @@ void Init_Type() {
     int i, bytes;
     char *p;
 
-    Num_Types = (sizeof(builtin_types) - 1) / sizeof(char *);
+    /* may be the next line led to the GC crash (both sc and gen).
+     * the first Define_Type gets 22, which is T_Broken_Heart
+     * (according to include/object.h).  crashes sc immediately and
+     * gen later, but only if objects of that first defined type are
+     * actually created */
+    /* Num_Types = (sizeof(builtin_types) - 1) / sizeof(char *); */
+    Num_Types = sizeof(builtin_types) / sizeof(char *);
     Max_Type = Num_Types + TYPE_GROW;
     bytes = Max_Type * sizeof(TYPEDESCR);
     Types = (TYPEDESCR *)Safe_Malloc(bytes);