[svn:parrot] r40893 - in trunk/src: call gc

NotFound at svn.parrot.org NotFound at svn.parrot.org
Mon Aug 31 20:34:38 UTC 2009


Author: NotFound
Date: Mon Aug 31 20:34:35 2009
New Revision: 40893
URL: https://trac.parrot.org/parrot/changeset/40893

Log:
[core] zero initialize stack-eating variables to avoid errors in gc stack trace

Modified:
   trunk/src/call/pcc.c
   trunk/src/gc/system.c

Modified: trunk/src/call/pcc.c
==============================================================================
--- trunk/src/call/pcc.c	Mon Aug 31 11:18:15 2009	(r40892)
+++ trunk/src/call/pcc.c	Mon Aug 31 20:34:35 2009	(r40893)
@@ -1886,6 +1886,8 @@
         dest_ctx->results_signature = NULL;
     }
 
+    memset(&st, 0, sizeof st);
+
     Parrot_init_arg_indexes_and_sig_pmc(interp, src_ctx, src_indexes,
         src_signature, &st.src);
 
@@ -2948,8 +2950,8 @@
     INTVAL n_regs_used[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
 
     /* Each of these is 8K. Do we want 16K on the stack? */
-    opcode_t arg_indexes[PCC_ARG_MAX];
-    opcode_t result_indexes[PCC_ARG_MAX];
+    opcode_t arg_indexes[PCC_ARG_MAX] = {0};
+    opcode_t result_indexes[PCC_ARG_MAX] = {0};
 
     /* create the signature string, and the various PMCs that are needed to
        store all the parameters and parameter counts. */

Modified: trunk/src/gc/system.c
==============================================================================
--- trunk/src/gc/system.c	Mon Aug 31 11:18:15 2009	(r40892)
+++ trunk/src/gc/system.c	Mon Aug 31 20:34:35 2009	(r40893)
@@ -409,6 +409,13 @@
 
 */
 
+PARROT_INLINE
+static void alive_mem_item(PARROT_INTERP, void *cur_var_ptr) /* HEADERIZER SKIP */
+{
+    const size_t ptr = *(size_t *)cur_var_ptr;
+    Parrot_gc_mark_PObj_alive(interp, (PObj *)ptr);
+}
+
 static void
 trace_mem_block(PARROT_INTERP, size_t lo_var_ptr, size_t hi_var_ptr)
 {
@@ -454,13 +461,13 @@
                 /* ...so ensure that Parrot_gc_mark_PObj_alive checks PObj_on_free_list_FLAG
                  * before adding it to the next_for_GC list, to have
                  * vtable->mark() called. */
-                Parrot_gc_mark_PObj_alive(interp, (PObj *)ptr);
+                alive_mem_item(interp, cur_var_ptr);
             }
             else if (buffer_min <= ptr && ptr < buffer_max &&
                     is_buffer_ptr(interp, (void *)ptr)) {
                 /* ...and since Parrot_gc_mark_PObj_alive doesn't care about bufstart, it
                  * doesn't really matter if it sets a flag */
-                Parrot_gc_mark_PObj_alive(interp, (PObj *)ptr);
+                alive_mem_item(interp, cur_var_ptr);
             }
         }
     }


More information about the parrot-commits mailing list