[svn:parrot] r39243 - in trunk: include/parrot src/interp src/runcore

chromatic at svn.parrot.org chromatic at svn.parrot.org
Fri May 29 23:47:07 UTC 2009


Author: chromatic
Date: Fri May 29 23:47:06 2009
New Revision: 39243
URL: https://trac.parrot.org/parrot/changeset/39243

Log:
[runcore] Plugged a memory leak when registering but never freeing dynop
libraries.

Modified:
   trunk/include/parrot/runcore_api.h
   trunk/src/interp/inter_create.c
   trunk/src/runcore/main.c

Modified: trunk/include/parrot/runcore_api.h
==============================================================================
--- trunk/include/parrot/runcore_api.h	Fri May 29 23:11:51 2009	(r39242)
+++ trunk/include/parrot/runcore_api.h	Fri May 29 23:47:06 2009	(r39243)
@@ -14,6 +14,66 @@
 
 #  define DO_OP(PC, INTERP) ((PC) = (((INTERP)->op_func_table)[*(PC)])((PC), (INTERP)))
 
+/* HEADERIZER BEGIN: src/runcore/main.c */
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
+
+PARROT_EXPORT
+void disable_event_checking(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+PARROT_EXPORT
+void enable_event_checking(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+void do_prederef(void **pc_prederef, PARROT_INTERP, int type)
+        __attribute__nonnull__(2);
+
+void dynop_register(PARROT_INTERP, PMC *lib_pmc)
+        __attribute__nonnull__(1);
+
+void exec_init_prederef(PARROT_INTERP, void *prederef_arena)
+        __attribute__nonnull__(1);
+
+PARROT_WARN_UNUSED_RESULT
+PARROT_CAN_RETURN_NULL
+void * init_jit(PARROT_INTERP, SHIM(opcode_t *pc))
+        __attribute__nonnull__(1);
+
+void Parrot_runcore_destroy(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+void Parrot_setup_event_func_ptrs(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+void prepare_for_run(PARROT_INTERP)
+        __attribute__nonnull__(1);
+
+void runops_int(PARROT_INTERP, size_t offset)
+        __attribute__nonnull__(1);
+
+#define ASSERT_ARGS_disable_event_checking __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_enable_event_checking __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_do_prederef __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_dynop_register __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_exec_init_prederef __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_init_jit __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_runcore_destroy __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_Parrot_setup_event_func_ptrs __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_prepare_for_run __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+#define ASSERT_ARGS_runops_int __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp)
+/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
+/* HEADERIZER END: src/runcore/main.c */
+
 /* HEADERIZER BEGIN: src/runcore/cores.c */
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 

Modified: trunk/src/interp/inter_create.c
==============================================================================
--- trunk/src/interp/inter_create.c	Fri May 29 23:11:51 2009	(r39242)
+++ trunk/src/interp/inter_create.c	Fri May 29 23:47:06 2009	(r39243)
@@ -374,10 +374,9 @@
   */
 
     /* we destroy all child interpreters and the last one too,
-     * if the --leak-test commandline was given
-     */
-    if (! (interp->parent_interpreter ||
-                Interp_flags_TEST(interp, PARROT_DESTROY_FLAG)))
+     * if the --leak-test commandline was given */
+    if (! (interp->parent_interpreter
+    ||    Interp_flags_TEST(interp, PARROT_DESTROY_FLAG)))
         return;
 
     if (interp->parent_interpreter
@@ -419,9 +418,6 @@
         interp->profile = NULL;
     }
 
-    /* deinit op_lib */
-    (void) PARROT_CORE_OPLIB_INIT(0);
-
     destroy_context(interp);
     destroy_runloop_jump_points(interp);
 
@@ -433,6 +429,8 @@
     /* strings, charsets, encodings - only once */
     Parrot_str_finish(interp);
 
+    PARROT_CORE_OPLIB_INIT(0);
+
     if (!interp->parent_interpreter) {
         if (interp->thread_data)
             mem_sys_free(interp->thread_data);
@@ -444,6 +442,9 @@
         if (interp->n_libs > 0) {
             mem_sys_free(interp->op_info_table);
             mem_sys_free(interp->op_func_table);
+
+            /* deinit op_lib */
+            Parrot_runcore_destroy();
         }
 
         MUTEX_DESTROY(interpreter_array_mutex);

Modified: trunk/src/runcore/main.c
==============================================================================
--- trunk/src/runcore/main.c	Fri May 29 23:11:51 2009	(r39242)
+++ trunk/src/runcore/main.c	Fri May 29 23:47:06 2009	(r39243)
@@ -49,7 +49,7 @@
 #include "../pmc/pmc_parrotlibrary.h"
 
 
-/* HEADERIZER HFILE: none */
+/* HEADERIZER HFILE: include/parrot/runcore_api.h */
 /* XXX Needs to get done at the same time as the other interpreter files */
 
 /* HEADERIZER BEGIN: static */
@@ -1034,6 +1034,36 @@
 
 /*
 
+=item C<void Parrot_runcore_destroy(PARROT_INTERP)>
+
+Shuts down the runcores and deallocates any dynops memory.
+
+=cut
+
+*/
+
+void
+Parrot_runcore_destroy(PARROT_INTERP)
+{
+    ASSERT_ARGS(Parrot_runcore_destroy)
+    op_lib_t    *cg_lib;
+
+#ifdef HAVE_COMPUTED_GOTO
+    cg_lib = PARROT_CORE_CGP_OPLIB_INIT(1);
+    if (cg_lib->op_func_table)
+        mem_sys_free(cg_lib->op_func_table);
+    cg_lib->op_func_table = NULL;
+
+    cg_lib = PARROT_CORE_CG_OPLIB_INIT(1);
+    if (cg_lib->op_func_table)
+        mem_sys_free(cg_lib->op_func_table);
+    cg_lib->op_func_table = NULL;
+#endif
+}
+
+
+/*
+
 =back
 
 =head2 Dynamic Loading Functions


More information about the parrot-commits mailing list