Navigation Menu

Skip to content

Commit

Permalink
2010-02-24 Zoltan Varga <vargaz@gmail.com>
Browse files Browse the repository at this point in the history
	* debugger-agent.c (notify_thread): Skip terminated threads, since their tls
	data is not freed yet. Fixes #582460.

svn path=/branches/mono-2-6/mono/; revision=152325
  • Loading branch information
vargaz committed Feb 24, 2010
1 parent 3bad19b commit 470de7a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
5 changes: 5 additions & 0 deletions mono/mini/ChangeLog
@@ -1,3 +1,8 @@
2010-02-24 Zoltan Varga <vargaz@gmail.com>

* debugger-agent.c (notify_thread): Skip terminated threads, since their tls
data is not freed yet. Fixes #582460.

2010-02-23 Zoltan Varga <vargaz@gmail.com>

* debugger-agent.c: Add support for the caught/uncaught flags on exception
Expand Down
41 changes: 21 additions & 20 deletions mono/mini/debugger-agent.c
Expand Up @@ -1937,34 +1937,35 @@ notify_thread (gpointer key, gpointer value, gpointer user_data)
DebuggerTlsData *tls = value;
gsize tid = thread->tid;

if (GetCurrentThreadId () != tid) {
DEBUG(1, fprintf (log_file, "[%p] Interrupting %p...\n", (gpointer)GetCurrentThreadId (), (gpointer)tid));
if (GetCurrentThreadId () == tid || tls->terminated)
return;

/*
* OSX can (and will) coalesce signals, so sending multiple pthread_kills does not
* guarantee the signal handler will be called that many times. Instead of tracking
* interrupt_count on osx, we use this as a boolean flag to determine if a interrupt
* has been requested that hasn't been handled yet, otherwise we can have threads
* refuse to die when VM_EXIT is called
*/
DEBUG(1, fprintf (log_file, "[%p] Interrupting %p...\n", (gpointer)GetCurrentThreadId (), (gpointer)tid));

/*
* OSX can (and will) coalesce signals, so sending multiple pthread_kills does not
* guarantee the signal handler will be called that many times. Instead of tracking
* interrupt_count on osx, we use this as a boolean flag to determine if a interrupt
* has been requested that hasn't been handled yet, otherwise we can have threads
* refuse to die when VM_EXIT is called
*/
#if defined(__APPLE__)
if (InterlockedCompareExchange (&tls->interrupt_count, 1, 0) == 1)
return;
if (InterlockedCompareExchange (&tls->interrupt_count, 1, 0) == 1)
return;
#else
/*
* Maybe we could use the normal interrupt infrastructure, but that does a lot
* of things like breaking waits etc. which we don't want.
*/
InterlockedIncrement (&tls->interrupt_count);
/*
* Maybe we could use the normal interrupt infrastructure, but that does a lot
* of things like breaking waits etc. which we don't want.
*/
InterlockedIncrement (&tls->interrupt_count);
#endif

/* This is _not_ equivalent to ves_icall_System_Threading_Thread_Abort () */
/* This is _not_ equivalent to ves_icall_System_Threading_Thread_Abort () */
#ifdef HOST_WIN32
QueueUserAPC (notify_thread_apc, thread->handle, NULL);
QueueUserAPC (notify_thread_apc, thread->handle, NULL);
#else
pthread_kill ((pthread_t) tid, mono_thread_get_abort_signal ());
pthread_kill ((pthread_t) tid, mono_thread_get_abort_signal ());
#endif
}
}

static void
Expand Down

0 comments on commit 470de7a

Please sign in to comment.