Author: chromatic
Date: Sat Jun 16 01:09:30 2007
New Revision: 19039

Modified:
   trunk/src/gc/register.c
   trunk/src/gc/resources.c
   trunk/src/inter_call.c

Log:
[PMC] Fixed a minor context memory leak in Continuation PMC.

Modified: trunk/src/gc/register.c
==============================================================================
--- trunk/src/gc/register.c     (original)
+++ trunk/src/gc/register.c     Sat Jun 16 01:09:30 2007
@@ -359,11 +359,10 @@
     const size_t size_s = sizeof (STRING*)  * n_regs_used[REGNO_STR];
     const size_t size_p = sizeof (PMC*)     * n_regs_used[REGNO_PMC];
 
-    const size_t size_nip = size_n + size_i + size_p;
-    const size_t all_regs_size  = size_n + size_i + size_p + size_s;
-
-    const size_t reg_alloc = ROUND_ALLOC_SIZE(all_regs_size);
-    const int slot = CALCULATE_SLOT_NUM(reg_alloc);
+    const size_t size_nip      = size_n + size_i + size_p;
+    const size_t all_regs_size = size_n + size_i + size_p + size_s;
+    const size_t reg_alloc     = ROUND_ALLOC_SIZE(all_regs_size);
+    const int    slot          = CALCULATE_SLOT_NUM(reg_alloc);
 
     /*
      * If slot is beyond the end of the allocated list, extend the list to
@@ -388,6 +387,7 @@
      */
     ptr = interp->ctx_mem.free_list[slot];
     old = CONTEXT(interp->ctx);
+
     if (ptr) {
         /*
          * Store the next pointer from the linked list for this size (slot
@@ -449,12 +449,13 @@
      * excecute "debug 0x80" in a (preferably small) test case.
      *
      */
-    if (re_use || --ctxp->ref_count == 0) {
+    if (re_use || --ctxp->ref_count <= 0) {
         void *ptr;
         int slot;
 
 #ifndef NDEBUG
-        if (Interp_debug_TEST(interp, PARROT_CTX_DESTROY_DEBUG_FLAG)) {
+        if (   Interp_debug_TEST(interp, PARROT_CTX_DESTROY_DEBUG_FLAG)
+            && ctxp->current_sub) {
             /* can't probably PIO_eprintf here */
             const Parrot_sub * const doomed = PMC_sub(ctxp->current_sub);
 

Modified: trunk/src/gc/resources.c
==============================================================================
--- trunk/src/gc/resources.c    (original)
+++ trunk/src/gc/resources.c    Sat Jun 16 01:09:30 2007
@@ -693,7 +693,7 @@
 FUNCDOC: Parrot_allocate_string
 
 Allocate the STRING's buffer memory to the given size. The allocated
-buffer maybe be slightly bigger than the given C<size>. This function
+buffer maybe slightly bigger than the given C<size>. This function
 sets also C<< str->strstart >> to the new buffer location, C<< str->bufused >>
 is B<not> changed.
 

Modified: trunk/src/inter_call.c
==============================================================================
--- trunk/src/inter_call.c      (original)
+++ trunk/src/inter_call.c      Sat Jun 16 01:09:30 2007
@@ -1472,6 +1472,7 @@
     interp->current_cont         = NEED_CONTINUATION;
     ctx->current_cont            = ret_cont;
     PMC_cont(ret_cont)->from_ctx = ctx;
+    ctx->ref_count++;
     pccinvoke_meth               = VTABLE_find_method(interp, pmc, 
method_name);
 
     if (PMC_IS_NULL(pccinvoke_meth))

Reply via email to