develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r35775 - in trunk: compilers/imcc include/parrot src src/gc

From:
infinoid
Date:
January 19, 2009 14:31
Subject:
[svn:parrot] r35775 - in trunk: compilers/imcc include/parrot src src/gc
Message ID:
20090119223117.6F2E8CB9AE@x12.develooper.com
Author: infinoid
Date: Mon Jan 19 14:31:16 2009
New Revision: 35775

Modified:
   trunk/compilers/imcc/main.c
   trunk/include/parrot/memory.h
   trunk/src/gc/memory.c
   trunk/src/inter_create.c
   trunk/src/interpreter.c

Log:
[core] The GC is being called too early, and didn't have enough stuff
set up yet to scan the stack effectively.  This caused early frees of
critical objects (in this case, the Scheduler) and crashed miniparrot
during the build process.  Initialize the stack pointer stuff earlier,
before the GC is enabled.  This fixes TT #179.

Modified: trunk/compilers/imcc/main.c
==============================================================================
--- trunk/compilers/imcc/main.c	(original)
+++ trunk/compilers/imcc/main.c	Mon Jan 19 14:31:16 2009
@@ -1041,11 +1041,6 @@
     yyscan_t           yyscanner   = IMCC_INFO(interp)->yyscanner;
     const char * const output_file = interp->output_file;
 
-    /* set the top of the stack so GC can trace it for GC-able pointers
-     * see trace_system_areas() in src/cpu_dep.c */
-    if (!interp->lo_var_ptr)
-        interp->lo_var_ptr = (void *)&obj_file;
-
     /* Figure out what kind of source file we have -- if we have one */
     if (!sourcefile || !*sourcefile)
         IMCC_fatal_standalone(interp, 1, "main: No source file specified.\n");

Modified: trunk/include/parrot/memory.h
==============================================================================
--- trunk/include/parrot/memory.h	(original)
+++ trunk/include/parrot/memory.h	Mon Jan 19 14:31:16 2009
@@ -111,8 +111,9 @@
     int line)
         __attribute__nonnull__(4);
 
-void mem_setup_allocator(PARROT_INTERP)
-        __attribute__nonnull__(1);
+void mem_setup_allocator(PARROT_INTERP, ARGIN(void *stacktop))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
 
 #define ASSERT_ARGS_mem_sys_allocate __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
 #define ASSERT_ARGS_mem_sys_allocate_zeroed __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
@@ -130,7 +131,8 @@
 #define ASSERT_ARGS_mem__internal_realloc_zeroed __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(file)
 #define ASSERT_ARGS_mem_setup_allocator __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp)
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(stacktop)
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 /* HEADERIZER END: src/gc/memory.c */
 

Modified: trunk/src/gc/memory.c
==============================================================================
--- trunk/src/gc/memory.c	(original)
+++ trunk/src/gc/memory.c	Mon Jan 19 14:31:16 2009
@@ -346,17 +346,22 @@
 Calls the initialization function associated with each collector, which
 is determined at compile time.
 
+The "stacktop" parameter is required; it provides an upper bound for
+stack scanning during a garbage collection run.
+
 =cut
 
 */
 
 void
-mem_setup_allocator(PARROT_INTERP)
+mem_setup_allocator(PARROT_INTERP, ARGIN(void *stacktop))
 {
     ASSERT_ARGS(mem_setup_allocator)
     interp->arena_base = mem_allocate_zeroed_typed(Arenas);
     interp->arena_base->sized_header_pools = NULL;
 
+    interp->lo_var_ptr = stacktop;
+
 #if PARROT_GC_MS
     Parrot_gc_ms_init(interp);
 #endif

Modified: trunk/src/inter_create.c
==============================================================================
--- trunk/src/inter_create.c	(original)
+++ trunk/src/inter_create.c	Mon Jan 19 14:31:16 2009
@@ -117,6 +117,7 @@
 make_interpreter(ARGIN_NULLOK(Interp *parent), INTVAL flags)
 {
     ASSERT_ARGS(make_interpreter)
+    int stacktop;
     Interp *interp;
 
     /* Get an empty interpreter from system memory */
@@ -167,7 +168,7 @@
     }
 
     /* Set up the memory allocation system */
-    mem_setup_allocator(interp);
+    mem_setup_allocator(interp, (void*)&stacktop);
     Parrot_block_GC_mark(interp);
     Parrot_block_GC_sweep(interp);
 

Modified: trunk/src/interpreter.c
==============================================================================
--- trunk/src/interpreter.c	(original)
+++ trunk/src/interpreter.c	Mon Jan 19 14:31:16 2009
@@ -889,14 +889,8 @@
 void
 runops_int(PARROT_INTERP, size_t offset)
 {
-    int lo_var_ptr;
     opcode_t *(*core) (PARROT_INTERP, opcode_t *) = NULL;
 
-    /* if we are entering the run loop the first time, set the stack pointer so
-     * that we can scan the stack for GCable pointers */
-    if (!interp->lo_var_ptr)
-        interp->lo_var_ptr = (void *)&lo_var_ptr;
-
     /* setup event function ptrs */
     if (!interp->save_func_table)
         Parrot_setup_event_func_ptrs(interp);



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About