help-smalltalk
[Top][All Lists]
Advanced

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

Re: [Help-smalltalk] [PATCH] gst-profile


From: Derek Zhou
Subject: Re: [Help-smalltalk] [PATCH] gst-profile
Date: Fri, 27 Feb 2009 22:47:28 -0800
User-agent: KMail/1.9.9

On Thursday 26 February 2009 11:35:58 pm Paolo Bonzini wrote:
> Do you have a simple example (I can use delta to minimize it, send it
> offlist if there are privacy problems of any kind).
> 
> Paolo
> 
This patch seems to fix my problem. What it does is to move the 
prepare_context call to before the SET_THIS_METHOD. Logically it should not
matter one way or the other but now that SET_THIS_METHOD may call the 
profiler which can allocate memory which in turn can trigger GC. If the 
context is not prepared correctly, GC may corrupt the memory and cause 
mystical crash. 

The above is just a theory and I have no solid proof that this is the problem
but my crashes do go away. I also do not have a good reason why fileIn seems
to have strong correlation with my crashes. I do believe this change is 
harmless at the very least.

Derek  

diff --git a/libgst/interp-bc.inl b/libgst/interp-bc.inl
index 34e68e4..970dd61 100644
--- a/libgst/interp-bc.inl
+++ b/libgst/interp-bc.inl
@@ -301,11 +304,11 @@ _gst_send_message_internal (OOP sendSelector,
 
   newContext = activate_new_context (header.stack_depth, sendArgs);
   newContext->flags = MCF_IS_METHOD_CONTEXT;
+  /* push args and temps, set sp and _gst_temporaries */
+  prepare_context ((gst_context_part) newContext, sendArgs, header.numTemps);
   SET_THIS_METHOD (methodOOP, 0);
   _gst_self = receiver;
 
-  /* push args and temps, set sp and _gst_temporaries */
-  prepare_context ((gst_context_part) newContext, sendArgs, header.numTemps);
 }
 
 void
@@ -388,11 +391,11 @@ _gst_send_method (OOP methodOOP)
   /* prepare new state */
   newContext = activate_new_context (header.stack_depth, sendArgs);
   newContext->flags = MCF_IS_METHOD_CONTEXT;
+  /* push args and temps, set sp and _gst_temporaries */
+  prepare_context ((gst_context_part) newContext, sendArgs, header.numTemps);
   SET_THIS_METHOD (methodOOP, 0);
   _gst_self = receiver;
 
-  /* push args and temps, set sp and _gst_temporaries */
-  prepare_context ((gst_context_part) newContext, sendArgs, header.numTemps);
 }
 
 
@@ -424,11 +427,11 @@ send_block_value (int numArgs, int cull_up_to)
     (gst_block_context) activate_new_context (header.depth, numArgs);
   closure = (gst_block_closure) OOP_TO_OBJ (closureOOP);
   blockContext->outerContext = closure->outerContext;
-  _gst_self = closure->receiver;
-  SET_THIS_METHOD (closure->block, 0);
-
   /* push args and temps */
   prepare_context ((gst_context_part) blockContext, numArgs, header.numTemps);
+  SET_THIS_METHOD (closure->block, 0);
+  _gst_self = closure->receiver;
+
   return (false);
 }
 






reply via email to

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