[svn:parrot] r41210 - in trunk/src: . interp pmc

NotFound at svn.parrot.org NotFound at svn.parrot.org
Fri Sep 11 14:27:07 UTC 2009


Author: NotFound
Date: Fri Sep 11 14:27:06 2009
New Revision: 41210
URL: https://trac.parrot.org/parrot/changeset/41210

Log:
[core] several fixes and ugly and maybe leaky workarounds to avoid segfault during destruction, TT #995 and others

Modified:
   trunk/src/interp/inter_create.c
   trunk/src/packfile.c
   trunk/src/pmc/eval.pmc

Modified: trunk/src/interp/inter_create.c
==============================================================================
--- trunk/src/interp/inter_create.c	Fri Sep 11 14:14:07 2009	(r41209)
+++ trunk/src/interp/inter_create.c	Fri Sep 11 14:27:06 2009	(r41210)
@@ -400,6 +400,12 @@
     /* copies of constant tables */
     Parrot_destroy_constants(interp);
 
+    destroy_runloop_jump_points(interp);
+
+    /* packfile */
+    if (interp->initial_pf)
+        PackFile_destroy(interp, interp->initial_pf);
+
     /* buffer headers, PMCs */
     Parrot_gc_destroy_header_pools(interp);
 
@@ -413,12 +419,6 @@
     /* cache structure */
     destroy_object_cache(interp);
 
-    /* packfile */
-    if (interp->initial_pf)
-        PackFile_destroy(interp, interp->initial_pf);
-
-    destroy_runloop_jump_points(interp);
-
     if (interp->evc_func_table) {
         mem_sys_free(interp->evc_func_table);
         interp->evc_func_table = NULL;

Modified: trunk/src/packfile.c
==============================================================================
--- trunk/src/packfile.c	Fri Sep 11 14:14:07 2009	(r41209)
+++ trunk/src/packfile.c	Fri Sep 11 14:27:06 2009	(r41210)
@@ -2201,12 +2201,24 @@
     PackFile_Directory * const dir = (PackFile_Directory *)self;
     size_t i;
 
-    for (i = 0; i < dir->num_segments; i++)
-        PackFile_Segment_destroy(interp, dir->segments[i]);
+    for (i = 0; i < dir->num_segments; i++) {
+        PackFile_Segment *segment = dir->segments[i];
+        /* Prevent repeated destruction */
+        dir->segments[i] = NULL;
+
+        /* XXX Black magic here.
+         * There are some failures that looks like a segment directory
+         * inserted into another. Until that problems gets fixed,
+         * these checks are a workaround.
+         */
+        if (segment && segment != self && segment->type != PF_DIR_SEG)
+            PackFile_Segment_destroy(interp, segment);
+    }
 
     if (dir->segments) {
         mem_sys_free(dir->segments);
         dir->segments = NULL;
+	dir->num_segments = 0;
     }
 }
 

Modified: trunk/src/pmc/eval.pmc
==============================================================================
--- trunk/src/pmc/eval.pmc	Fri Sep 11 14:14:07 2009	(r41209)
+++ trunk/src/pmc/eval.pmc	Fri Sep 11 14:27:06 2009	(r41210)
@@ -185,20 +185,25 @@
             return;
         }
 
-        /* Quick and dirty fix for TT #995 */
-        if ((struct PackFile *)cur_cs == interp->initial_pf) {
+        /* XXX Quick and dirty fix for TT #995 */
+        if ((struct PackFile *)cur_cs == interp->initial_pf
+	        || cur_cs == interp->code) {
             SUPER();
             return;
         }
 
         /* RT#46685 create PF API, move it there */
         seg = (PackFile_Segment *)cur_cs->const_table;
-        if (seg)
+        if (seg) {
             PackFile_Segment_destroy(INTERP, seg);
+            cur_cs->const_table = NULL;
+        }
 
         seg = (PackFile_Segment *)cur_cs->debugs;
-        if (seg)
+        if (seg) {
             PackFile_Segment_destroy(INTERP, seg);
+            cur_cs->debugs = NULL;
+        }
 
         seg = (PackFile_Segment *)cur_cs->fixups;
         if (seg) {
@@ -207,14 +212,22 @@
         }
 
         seg = cur_cs->pic_index;
-        if (seg)
+        if (seg) {
             PackFile_Segment_destroy(INTERP, seg);
+            cur_cs->pic_index = NULL;
+        }
+
+/* XXX Commenting out this to fix TT #995 and related problems.
+ * May leak some memory, need further revision.
 
         seg = (PackFile_Segment *)cur_cs;
         if (seg)
             PackFile_Segment_destroy(INTERP, seg);
+ * XXX End of commented out section.
+ */
 
         sub_data->seg = NULL;
+
         SUPER();
     }
 


More information about the parrot-commits mailing list