help-smalltalk
[Top][All Lists]
Advanced

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

[Help-smalltalk] Re: [GNU Smalltalk 3.0] testsuite: 117 failed


From: Paolo Bonzini
Subject: [Help-smalltalk] Re: [GNU Smalltalk 3.0] testsuite: 117 failed
Date: Mon, 14 Jan 2008 22:10:12 +0100
User-agent: Thunderbird 2.0.0.9 (Macintosh/20071031)

Hi,

I'm absolutely not sure that this patch will fix it, but it might. I don't see other places where there could be a GC bug.

Now, this is exactly the patch I *don't* want to put in a minor release. But this particular bug seems frequent, and a GC bug anyway has to be fixed as soon as possible.

Thanks!

Paolo
diff --git a/libgst/prims.def b/libgst/prims.def
index 745d902..05ab2ce 100644
--- a/libgst/prims.def
+++ b/libgst/prims.def
@@ -2204,16 +2204,17 @@ primitive VMpr_CompiledCode_verificationResult [succeed]
 /* CompiledBlock numArgs:numTemps:bytecodes:depth:literals: */
 primitive VMpr_CompiledBlock_create [succeed]
 {
-  OOP *_gst_literals = OOP_TO_OBJ (POP_OOP ())->data;
-  int depth = TO_INT (POP_OOP ());
-  OOP bytecodesOOP = POP_OOP ();
-  int blockTemps = TO_INT (POP_OOP ());
-  int blockArgs = TO_INT (POP_OOP ());
+  OOP *_gst_literals = OOP_TO_OBJ (STACK_AT (0))->data;
+  int depth = TO_INT (STACK_AT (1));
+  OOP bytecodesOOP = STACK_AT (2);
+  int blockTemps = TO_INT (STACK_AT (3));
+  int blockArgs = TO_INT (STACK_AT (4));
   bc_vector bytecodes = _gst_extract_bytecodes (bytecodesOOP);
 
   OOP block =
     _gst_block_new (blockArgs, blockTemps, bytecodes, depth, _gst_literals);
 
+  POP_N_OOPS (5);
   OOP_CLASS(block) = STACKTOP ();
 
   _gst_primitives_executed++;
@@ -2236,12 +2237,11 @@ primitive VMpr_CompiledMethod_create [succeed,fail]
   if (primitive == -1)
     PRIM_FAILED;
 
-  POP_N_OOPS(6);
-
   method = _gst_make_new_method (primitive, methodArgs, methodTemps, depth,
                                 literals, bytecodes, _gst_nil_oop,
                                 _gst_nil_oop, _gst_nil_oop, -1, -1);
 
+  POP_N_OOPS(6);
   OOP_CLASS(method) = STACKTOP ();
 
   _gst_primitives_executed++;
@@ -3916,22 +3916,21 @@ primitive VMpr_CObject_allocType [succeed,fail]
   OOP oop3;
   _gst_primitives_executed++;
 
-  oop1 = POP_OOP ();
-  oop2 = POP_OOP ();
-  oop3 = STACKTOP ();
+  oop1 = STACK_AT (0);
+  oop2 = STACK_AT (1);
+  oop3 = STACK_AT (2);
   if (IS_INT (oop2)
       && (IS_NIL (oop1) || is_a_kind_of (OOP_CLASS (oop1), _gst_c_type_class))
       && COMMON (RECEIVER_IS_A_KIND_OF (oop3, _gst_c_object_class)))
     {
-      intptr_t arg2;
-      PTR ptr;
-      arg2 = TO_INT (oop2);
-      ptr = xmalloc (arg2);
+      intptr_t arg2 = TO_INT (oop2);
+      PTR ptr = xmalloc (arg2);
+      OOP cObjectOOP = _gst_c_object_new (ptr, oop1, oop3);
 
-      SET_STACKTOP (_gst_c_object_new (ptr, oop1, oop3));
+      POP_N_OOPS (2);
+      SET_STACKTOP (cObjectOOP);
       PRIM_SUCCEEDED;
     }
-  UNPOP (2);
   PRIM_FAILED;
 }
 
@@ -4752,62 +4751,63 @@ primitive VMpr_CString_replaceWith [succeed,fail]
 /* ByteArray class fromCdata: aCObject size: anInteger */
 primitive VMpr_ByteArray_fromCData_size [succeed,fail]
 {
-  OOP oop1;
   OOP oop2;
   OOP oop3;
   _gst_primitives_executed++;
 
-  oop3 = POP_OOP ();
-  oop2 = POP_OOP ();
-  oop1 = STACKTOP ();
-  if (IS_INT (oop3))
+  oop3 = STACK_AT (0);
+  oop2 = STACK_AT (1);
+  if (IS_INT (oop3)
+      && is_a_kind_of (OOP_CLASS (oop2), _gst_c_object_class))
     {
       intptr_t arg3 = TO_INT (oop3);
       OOP byteArrayOOP =
        _gst_byte_array_new (COBJECT_VALUE (oop2), arg3);
+      POP_N_OOPS (2);
       SET_STACKTOP (byteArrayOOP);
       PRIM_SUCCEEDED;
     }
-  UNPOP (2);
   PRIM_FAILED;
 }
 
 /* String class fromCdata: aCObject size: anInteger */
 primitive VMpr_String_fromCData_size [succeed,fail]
 {
-  OOP oop1;
   OOP oop2;
   OOP oop3;
   _gst_primitives_executed++;
 
-  oop3 = POP_OOP ();
-  oop2 = POP_OOP ();
-  oop1 = STACKTOP ();
-  if (IS_INT (oop3))
+  oop3 = STACK_AT (0);
+  oop2 = STACK_AT (1);
+  if (IS_INT (oop3)
+      && is_a_kind_of (OOP_CLASS (oop2), _gst_c_object_class))
     {
       intptr_t arg3 = TO_INT (oop3);
       OOP stringOOP =
        _gst_counted_string_new (COBJECT_VALUE (oop2), arg3);
+      POP_N_OOPS (2);
       SET_STACKTOP (stringOOP);
       PRIM_SUCCEEDED;
     }
-  UNPOP (2);
   PRIM_FAILED;
 }
 
 /* String class fromCdata: aCObject */
 primitive VMpr_String_fromCData [succeed]
 {
-  OOP oop1;
   OOP oop2;
   OOP stringOOP;
   _gst_primitives_executed++;
 
-  oop2 = POP_OOP ();
-  oop1 = STACKTOP ();
-  stringOOP = _gst_string_new (COBJECT_VALUE (oop2));
-  SET_STACKTOP (stringOOP);
-  PRIM_SUCCEEDED;
+  oop2 = STACKTOP ();
+  if (is_a_kind_of (OOP_CLASS (oop2), _gst_c_object_class))
+    {
+      stringOOP = _gst_string_new (COBJECT_VALUE (oop2));
+      POP_OOP ();
+      SET_STACKTOP (stringOOP);
+      PRIM_SUCCEEDED;
+    }
+  PRIM_FAILED;
 }
 
 /* String asCdata: aCType
@@ -4822,8 +4822,8 @@ primitive VMpr_String_ByteArray_asCData :
   OOP oop2;
   _gst_primitives_executed++;
 
-  oop2 = POP_OOP ();
-  oop1 = STACKTOP ();
+  oop2 = STACK_AT (0);
+  oop1 = STACK_AT (1);
 #ifndef OPTIMIZE
   if ((IS_CLASS (oop1, _gst_string_class)
        && id == prim_id (VMpr_String_asCData))
@@ -4838,6 +4838,7 @@ primitive VMpr_String_ByteArray_asCData :
          if (data)
            {
              memcpy (data, OOP_TO_OBJ (oop1)->data, size);
+             POP_OOP ();
              SET_STACKTOP (_gst_c_object_new (data, oop2, 
_gst_c_object_class));
              PRIM_SUCCEEDED;
            }
@@ -4845,7 +4846,6 @@ primitive VMpr_String_ByteArray_asCData :
 #ifndef OPTIMIZE
     }
 #endif
-  UNPOP (1);
   PRIM_FAILED;
 }
 
@@ -5032,16 +5032,14 @@ primitive VMpr_Behavior_primCompileIfError 
[fail,succeed,reload_ip]
            withArgs: argsArray */
 primitive VMpr_CFuncDescriptor_create [succeed,fail]
 {
-  OOP oop1;
   OOP oop2;
   OOP oop3;
   OOP oop4;
   _gst_primitives_executed++;
 
-  oop4 = POP_OOP ();
-  oop3 = POP_OOP ();
-  oop2 = POP_OOP ();
-  oop1 = POP_OOP ();
+  oop4 = STACK_AT (0);
+  oop3 = STACK_AT (1);
+  oop2 = STACK_AT (2);
 
   if (IS_CLASS (oop2, _gst_string_class)
       && (IS_CLASS (oop3, _gst_symbol_class)
@@ -5049,11 +5047,13 @@ primitive VMpr_CFuncDescriptor_create [succeed,fail]
       && (IS_CLASS (oop4, _gst_array_class)
          || IS_CLASS (oop4, _gst_undefined_object_class)))
     {
-      PUSH_OOP (_gst_make_descriptor (oop2, oop3, oop4));
+      OOP cFuncDescrOOP = _gst_make_descriptor (oop2, oop3, oop4);
+      POP_N_OOPS (3);
+      SET_STACKTOP (cFuncDescrOOP);
       PRIM_SUCCEEDED;
     }
-  UNPOP (4);
-  PRIM_FAILED;
+  else
+    PRIM_FAILED;
 }
 
 /* Object snapshot: aString */
@@ -5159,11 +5159,10 @@ primitive VMpr_FileDescriptor_fileOp [succeed,fail]
     oopVec[i] = POP_OOP ();
 
   oop1 = STACKTOP ();
+  UNPOP (numArgs);
+
   if (!IS_INT (oopVec[0]))
-    {
-      UNPOP (numArgs);
-      PRIM_FAILED;
-    }
+    PRIM_FAILED;
 
   arg1 = TO_INT (oopVec[0]);
   switch (arg1) {
@@ -5215,16 +5214,14 @@ primitive VMpr_FileDescriptor_fileOp [succeed,fail]
 
       xfree (fileName);
       if (fd < 0)
-        {
-         UNPOP (numArgs);
-         PRIM_FAILED;
-        }
+       PRIM_FAILED;
 
       _gst_set_file_stream_file (oop1, fd, oopVec[1],
                                 is_pipe, access, false);
-    }
 
-    PRIM_SUCCEEDED;
+      POP_N_OOPS (numArgs);
+      PRIM_SUCCEEDED;
+    }
 
   case PRIM_MK_TEMP:
     fileName = _gst_to_cstring (oopVec[1]);
@@ -5235,7 +5232,6 @@ primitive VMpr_FileDescriptor_fileOp [succeed,fail]
     if (fd < 0)
       {
         xfree (fileName2);
-       UNPOP (numArgs);
        PRIM_FAILED;
       }
     
@@ -5248,10 +5244,7 @@ primitive VMpr_FileDescriptor_fileOp [succeed,fail]
 
   fileStream = (gst_file_stream) OOP_TO_OBJ (oop1);
   if (!IS_INT (fileStream->file))
-    {
-      UNPOP (numArgs);
-      PRIM_FAILED;
-    }
+    PRIM_FAILED;
 
   fd = TO_INT (fileStream->file);
   switch (arg1)
@@ -5269,7 +5262,10 @@ primitive VMpr_FileDescriptor_fileOp [succeed,fail]
          break;
        }
       else
-       PRIM_SUCCEEDED;
+        {
+         POP_N_OOPS (numArgs);
+         PRIM_SUCCEEDED;
+       }
 
     case PRIM_FTELL:           /* FileDescriptor position */
       {
@@ -5321,6 +5317,7 @@ primitive VMpr_FileDescriptor_fileOp [succeed,fail]
              result = _gst_write (fd, data + from - 1, to - from + 1);
              if (result >= 0)
                {
+                 POP_N_OOPS (numArgs);
                  SET_STACKTOP_INT (result);
                  PRIM_SUCCEEDED;
                }
@@ -5347,6 +5344,7 @@ primitive VMpr_FileDescriptor_fileOp [succeed,fail]
 
              if (result >= 0)
                {
+                 POP_N_OOPS (numArgs);
                  SET_STACKTOP_INT (result);
                  PRIM_SUCCEEDED;
                }
@@ -5387,6 +5385,7 @@ primitive VMpr_FileDescriptor_fileOp [succeed,fail]
 
              if (result >= 0)
                {
+                 POP_N_OOPS (numArgs);
                  SET_STACKTOP_INT (result);
                  PRIM_SUCCEEDED;
                }
@@ -5427,6 +5426,7 @@ primitive VMpr_FileDescriptor_fileOp [succeed,fail]
 
              if (result >= 0)
                {
+                 POP_N_OOPS (numArgs);
                  SET_STACKTOP_INT (result);
                  PRIM_SUCCEEDED;
                }
@@ -5442,6 +5442,7 @@ primitive VMpr_FileDescriptor_fileOp [succeed,fail]
          break;
 
        ftruncate (fd, pos);
+       POP_N_OOPS (numArgs);
        PRIM_SUCCEEDED;
       }
 
@@ -5450,7 +5451,10 @@ primitive VMpr_FileDescriptor_fileOp [succeed,fail]
          lseek (fd, TO_OFF_T (oopVec[1]), SEEK_CUR) < 0)
        break;
       else
-       PRIM_SUCCEEDED;
+       {
+         POP_N_OOPS (numArgs);
+         PRIM_SUCCEEDED;
+       }
 
     case PRIM_SYNC_POLL:
       {
@@ -5459,6 +5463,7 @@ primitive VMpr_FileDescriptor_fileOp [succeed,fail]
        result = _gst_sync_file_polling (fd, TO_INT (oopVec[1]));
        if (result >= 0)
          {
+           POP_N_OOPS (numArgs);
            SET_STACKTOP_INT (result);
            PRIM_SUCCEEDED;
          }
@@ -5472,7 +5477,10 @@ primitive VMpr_FileDescriptor_fileOp [succeed,fail]
        result =
          _gst_async_file_polling (fd, TO_INT (oopVec[1]), oopVec[2]);
        if (result >= 0)
-         PRIM_SUCCEEDED;
+         {
+           POP_N_OOPS (numArgs);
+           PRIM_SUCCEEDED;
+         }
       }
       break;
 
@@ -5517,7 +5525,6 @@ primitive VMpr_FileDescriptor_fileOp [succeed,fail]
   if (errno)
     _gst_set_errno (errno);
 
-  UNPOP (numArgs);
   PRIM_FAILED;
 }
 
@@ -5538,20 +5545,16 @@ primitive VMpr_FileDescriptor_socketOp [succeed,fail]
   for (i = numArgs; --i >= 0;)
     oopVec[i] = POP_OOP ();
 
+  UNPOP (numArgs);
   oop1 = STACKTOP ();
   if (!IS_INT (oopVec[0]))
-    {
-      UNPOP (numArgs);
-      PRIM_FAILED;
-    }
+    PRIM_FAILED;
 
   arg1 = TO_INT (oopVec[0]);
   fileStream = (gst_file_stream) OOP_TO_OBJ (oop1);
   if (IS_NIL (fileStream->file))
-    {
-      UNPOP (numArgs);
-      PRIM_FAILED;
-    }
+    PRIM_FAILED;
+
   fd = TO_INT (fileStream->file);
   switch (arg1)
     {
@@ -5560,6 +5563,7 @@ primitive VMpr_FileDescriptor_socketOp [succeed,fail]
       {
         int result = closesocket (fd);
         SET_STACKTOP_INT (result);
+       POP_N_OOPS (numArgs);
         PRIM_SUCCEEDED;
       }
 
@@ -5580,6 +5584,7 @@ primitive VMpr_FileDescriptor_socketOp [succeed,fail]
                abort ();
              if (result >= 0)
                {
+                 POP_N_OOPS (numArgs);
                  SET_STACKTOP_INT (result);
                  PRIM_SUCCEEDED;
                }
@@ -5614,6 +5619,7 @@ primitive VMpr_FileDescriptor_socketOp [succeed,fail]
 
              if (result >= 0)
                {
+                 POP_N_OOPS (numArgs);
                  SET_STACKTOP_INT (result);
                  PRIM_SUCCEEDED;
                }
@@ -5628,6 +5634,7 @@ primitive VMpr_FileDescriptor_socketOp [succeed,fail]
        result = _gst_sync_file_polling (fd, TO_INT (oopVec[1]));
        if (result >= 0)
          {
+           POP_N_OOPS (numArgs);
            SET_STACKTOP_INT (result);
            PRIM_SUCCEEDED;
          }
@@ -5641,7 +5648,10 @@ primitive VMpr_FileDescriptor_socketOp [succeed,fail]
        result =
          _gst_async_file_polling (fd, TO_INT (oopVec[1]), oopVec[2]);
        if (result >= 0)
-         PRIM_SUCCEEDED;
+         {
+           POP_N_OOPS (numArgs);
+           PRIM_SUCCEEDED;
+         }
       }
       break;
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]