Permalink
Browse files

Fix another bunch of shutdown leaks.

  • Loading branch information...
1 parent 11a4a51 commit 653f2a1cc0a44ca99affd0de42c519f9a1c86c30 @vargaz vargaz committed Aug 20, 2010
View
@@ -1742,6 +1742,7 @@ mono_cleanup (void)
mono_assembly_close (mono_defaults.corlib->assembly);
mono_defaults.corlib = NULL;
+ mono_config_cleanup ();
mono_loader_cleanup ();
mono_classes_cleanup ();
mono_assemblies_cleanup ();
View
@@ -125,7 +125,14 @@ mono_monitor_init (void)
void
mono_monitor_cleanup (void)
{
+ MonitorArray *marray, *next = NULL;
+
/*DeleteCriticalSection (&monitor_mutex);*/
+
+ for (marray = monitor_allocated; marray; marray = next) {
+ next = marray->next;
+ g_free (marray);
+ }
}
/*
@@ -132,6 +132,9 @@ mono_parser = {
static GHashTable *config_handlers;
+static const char *mono_cfg_dir = NULL;
+static char *mono_cfg_dir_allocated = NULL;
+
/* when this interface is stable, export it. */
typedef struct MonoParseHandler MonoParseHandler;
@@ -368,6 +371,13 @@ mono_config_init (void)
g_hash_table_insert (config_handlers, (gpointer) legacyUEP_handler.element_name, (gpointer) &legacyUEP_handler);
}
+void
+mono_config_cleanup (void)
+{
+ g_hash_table_destroy (config_handlers);
+ g_free (mono_cfg_dir_allocated);
+}
+
/* FIXME: error handling */
static void
@@ -567,16 +577,14 @@ mono_config_parse (const char *filename) {
#endif
}
-static const char *mono_cfg_dir = NULL;
-
/* Invoked during startup */
void
mono_set_config_dir (const char *dir)
{
/* If this variable is set, overrides the directory computed */
mono_cfg_dir = g_getenv ("MONO_CFG_DIR");
if (mono_cfg_dir == NULL)
- mono_cfg_dir = g_strdup (dir);
+ mono_cfg_dir = mono_cfg_dir_allocated = g_strdup (dir);
}
const char*
@@ -18,6 +18,7 @@ void mono_set_config_dir (const char *dir);
const char* mono_get_machine_config (void);
+void mono_config_cleanup (void);
void mono_config_parse (const char *filename);
void mono_config_for_assembly (MonoImage *assembly);
void mono_config_parse_memory (const char *buffer);
View
@@ -79,6 +79,9 @@ get_default_field_value (MonoDomain* domain, MonoClassField *field, void *value)
static MonoString*
mono_ldstr_metadata_sig (MonoDomain *domain, const char* sig);
+static void
+free_main_args (void);
+
#define ldstr_lock() EnterCriticalSection (&ldstr_section)
#define ldstr_unlock() LeaveCriticalSection (&ldstr_section)
static CRITICAL_SECTION ldstr_section;
@@ -189,6 +192,8 @@ mono_type_initialization_cleanup (void)
DeleteCriticalSection (&ldstr_section);
g_hash_table_destroy (type_initialization_hash);
g_hash_table_destroy (blocked_thread_hash);
+
+ free_main_args ();
}
/**
@@ -3342,6 +3347,16 @@ mono_runtime_get_main_args (void)
return res;
}
+static void
+free_main_args (void)
+{
+ int i;
+
+ for (i = 0; i < num_main_args; ++i)
+ g_free (main_args [i]);
+ g_free (main_args);
+}
+
/**
* mono_runtime_run_main:
* @method: the method to start the application with (usually Main)
View
@@ -3808,8 +3808,14 @@ do_free_special (gpointer key, gpointer value, gpointer data)
mono_g_hash_table_foreach (threads, free_thread_static_data_helper, &data);
item->offset = offset;
item->size = size;
- item->next = thread_static_info.freelist;
- thread_static_info.freelist = item;
+
+ if (!mono_runtime_is_shutting_down ()) {
+ item->next = thread_static_info.freelist;
+ thread_static_info.freelist = item;
+ } else {
+ /* We could be called during shutdown after mono_thread_cleanup () is called */
+ g_free (item);
+ }
} else {
/* FIXME: free context static data as well */
}

0 comments on commit 653f2a1

Please sign in to comment.