Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@lambdageek
Copy link
Member

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 dotnet/android#2920

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 dotnet/android#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
```
@lambdageek
Copy link
Member Author

Is 2018-08-rc the correct branch for this PR?

@lambdageek lambdageek changed the title [debugger-agent] Ignore thread_end event if thread is detached [2018-08-rc][debugger-agent] Ignore thread_end event if thread is detached Apr 8, 2019
@lambdageek
Copy link
Member Author

The crash looked like this:

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=, arg=, il_offset=, ctx=, events=, suspend_policy=) 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=, tid=) at debugger-agent.c:3991
    frame #6: libmonosgen-2.0.so`mono_profiler_raise_thread_stopped(tid=) at profiler-events.h:105
    frame #7: libmonosgen-2.0.so`mono_thread_detach_internal(thread=) 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=) 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

@lambdageek lambdageek requested review from marek-safar and vargaz April 8, 2019 21:15
@jonpryor
Copy link
Contributor

jonpryor commented Apr 8, 2019

@lambdageek: mono/2018-08-rc (d16-0) and mono/2018-08 (d16-1) will each need this fix, as well as mono/2019-02 and mono/2019-04 (assuming integration work isn't abandoned).

@lambdageek
Copy link
Member Author

@monojenkins backport to 2018-08
@monojenkins backport to 2018-10
@monojenkins backport to 2019-02

@lewurm
Copy link
Contributor

lewurm commented Apr 9, 2019

@monojenkins build failed

@lambdageek
Copy link
Member Author

lambdageek commented Apr 9, 2019

I think this is passing all the lanes that it is expected to pass:

  • C++ - these are disabled on the normal 2018-08 branch (if you look at the log over on [2018-08] [debugger-agent] Ignore thread_end event if thread is detached #13937 - there's a check and the test aborts without building or running anything)
  • All of these are new on master
    • Linux x64 -prefix sanity check
    • Windows x64 FullAOT
  • These are not required on the normal 2018-08 branch.
    • Linux AArch64 FullAOT+Interpreter+LLVM
    • Linux x64 FullAOT+Interpreter+LLVM
    • OSX x64 iOS SDK

@lambdageek lambdageek merged commit 5ac37cc into mono:2018-08-rc Apr 9, 2019
@marek-safar
Copy link
Member

@monojenkins backport to 2019-04

@lambdageek
Copy link
Member Author

@monojenkins backport to 2019-06
@monojenkins backport to master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants