Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormonojenkins <jo.shields+jenkins@xamarin.com>2019-04-09 17:39:24 +0300
committerAleksey Kliger (λgeek) <akliger@gmail.com>2019-04-09 17:39:24 +0300
commit886c49017470112af1a73034d8951d6ca00b641e (patch)
tree857064b387e37c5b2fc6f907e1635cd81b654ab0
parentbd6801d40222b69966b7c17e4f1674214c435962 (diff)
[debugger-agent] Ignore thread_end event if thread is detached (#13939)mono-5.20.1.19
The thread_stopped profiler event can be raised by the thread_info_key_dtor tls key destructor when the thread is already doesn't have a domain set. In that case, don't call process_profiler_event since it cannot handle a thread with null TLS values. Addresses https://github.com/xamarin/xamarin-android/issues/2920 with the following stack trace ``` * thread #20, name = 'Filter', stop reason = signal SIGSEGV: invalid address (fault address: 0xbc) * frame #0: libmonosgen-2.0.so`mono_class_vtable_checked(domain=0x0000000000000000, klass=0x0000007200230648, error=0x00000071e92f9178) at object.c:1890 frame #1: libmonosgen-2.0.so`get_current_thread_ptr_for_domain(domain=0x0000000000000000, thread=0x00000071ebfec508) at threads.c:595 frame #2: libmonosgen-2.0.so`mono_thread_current at threads.c:1939 frame #3: libmonosgen-2.0.so`process_event(event=<unavailable>, arg=<unavailable>, il_offset=<unavailable>, ctx=<unavailable>, events=<unavailable>, suspend_policy=<unavailable>) at debugger-agent.c:3715 frame #4: libmonosgen-2.0.so`thread_end [inlined] process_profiler_event(event=EVENT_KIND_THREAD_DEATH, arg=0x00000071ebfec508) at debugger-agent.c:3875 frame #5: libmonosgen-2.0.so`thread_end(prof=<unavailable>, tid=<unavailable>) at debugger-agent.c:3991 frame #6: libmonosgen-2.0.so`mono_profiler_raise_thread_stopped(tid=<unavailable>) at profiler-events.h:105 frame #7: libmonosgen-2.0.so`mono_thread_detach_internal(thread=<unavailable>) at threads.c:979 frame #8: libmonosgen-2.0.so`thread_detach(info=0x00000071e949a000) at threads.c:3215 frame #9: libmonosgen-2.0.so`unregister_thread(arg=<unavailable>) at mono-threads.c:544 frame #10: libmonosgen-2.0.so`thread_info_key_dtor(arg=0x00000071e949a000) at mono-threads.c:774 frame #11: 0x00000072899c58e8 libc.so`pthread_key_clean_all() + 124 frame #12: 0x00000072899c5374 libc.so`pthread_exit + 76 frame #13: 0x00000072899c5264 libc.so`__pthread_start(void*) + 44 frame #14: 0x000000728996617c libc.so`__start_thread + 72 ```
-rw-r--r--mono/mini/debugger-agent.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c
index 7714b37be70..d6bd7421fad 100644
--- a/mono/mini/debugger-agent.c
+++ b/mono/mini/debugger-agent.c
@@ -3977,13 +3977,17 @@ thread_end (MonoProfiler *prof, uintptr_t tid)
/* We might be called for threads started before we registered the start callback */
if (thread) {
- DEBUG_PRINTF (1, "[%p] Thread terminated, obj=%p, tls=%p.\n", (gpointer)tid, thread, tls);
+ DEBUG_PRINTF (1, "[%p] Thread terminated, obj=%p, tls=%p (domain=%p).\n", (gpointer)tid, thread, tls, (gpointer)mono_domain_get ());
- if (mono_thread_internal_is_current (thread) && !mono_native_tls_get_value (debugger_tls_id)
+ if (mono_thread_internal_is_current (thread) &&
+ (!mono_native_tls_get_value (debugger_tls_id) ||
+ !mono_domain_get ())
) {
/*
- * This can happen on darwin since we deregister threads using pthread dtors.
- * process_profiler_event () and the code it calls cannot handle a null TLS value.
+ * This can happen on darwin and android since we
+ * deregister threads using pthread dtors.
+ * process_profiler_event () and the code it calls
+ * cannot handle a null TLS value.
*/
return;
}