void mono_thread_manage (void)
{
- struct wait_data *wait=g_new0 (struct wait_data, 1);
+ struct wait_data wait_data;
+ struct wait_data *wait = &wait_data;
+ memset (wait, 0, sizeof (struct wait_data));
/* join each thread that's still running */
THREAD_DEBUG (g_message ("%s: Joining each running thread...", __func__));
if(threads==NULL) {
THREAD_DEBUG (g_message("%s: No threads", __func__));
mono_threads_unlock ();
- g_free (wait);
return;
}
mono_threads_unlock ();
ResetEvent (background_change_event);
wait->num=0;
+ /*We must zero all InternalThread pointers to avoid making the GC unhappy.*/
+ memset (wait->threads, 0, MAXIMUM_WAIT_OBJECTS * SIZEOF_VOID_P);
mono_g_hash_table_foreach (threads, build_wait_tids, wait);
mono_threads_unlock ();
if(wait->num>0) {
mono_threads_lock ();
wait->num = 0;
+ /*We must zero all InternalThread pointers to avoid making the GC unhappy.*/
+ memset (wait->threads, 0, MAXIMUM_WAIT_OBJECTS * SIZEOF_VOID_P);
mono_g_hash_table_foreach_remove (threads, remove_and_abort_threads, wait);
mono_threads_unlock ();
#ifndef HOST_WIN32
sched_yield ();
#endif
-
- g_free (wait);
}
static void terminate_thread (gpointer key, gpointer value, gpointer user)
*/
void mono_thread_suspend_all_other_threads (void)
{
- struct wait_data *wait = g_new0 (struct wait_data, 1);
+ struct wait_data wait_data;
+ struct wait_data *wait = &wait_data;
int i;
gsize self = GetCurrentThreadId ();
gpointer *events;
guint32 eventidx = 0;
gboolean starting, finished;
+ memset (wait, 0, sizeof (struct wait_data));
/*
* The other threads could be in an arbitrary state at this point, i.e.
* they could be starting up, shutting down etc. This means that there could be
* threads while threads_mutex is held.
*/
wait->num = 0;
+ /*We must zero all InternalThread pointers to avoid making the GC unhappy.*/
+ memset (wait->threads, 0, MAXIMUM_WAIT_OBJECTS * SIZEOF_VOID_P);
mono_threads_lock ();
mono_g_hash_table_foreach (threads, collect_threads_for_suspend, wait);
mono_threads_unlock ();
g_free (events);
}
-
- g_free (wait);
}
static void
void
mono_threads_request_thread_dump (void)
{
- struct wait_data *wait = g_new0 (struct wait_data, 1);
+ struct wait_data wait_data;
+ struct wait_data *wait = &wait_data;
int i;
+ memset (wait, 0, sizeof (struct wait_data));
+
/*
* Make a copy of the hashtable since we can't do anything with
* threads while threads_mutex is held.