Prevent a possible assert in the debugger when a thread detaches (#34955)
authormonojenkins <jo.shields+jenkins@xamarin.com>
Fri, 24 Apr 2020 10:52:31 +0000 (06:52 -0400)
committerGitHub <noreply@github.com>
Fri, 24 Apr 2020 10:52:31 +0000 (12:52 +0200)
commit1ef04f8a08d96192a610d580a865b269bf2d9203
treecc510b8e65331fe616e8236aab834d71b77b5cd2
parent9af1c5e4b072b88b78fcc2d35a350ad4db737c3c
Prevent a possible assert in the debugger when a thread detaches (#34955)

When a new thread is attached to the VM, the debugger will add it to the
`thread_to_tls` hash table. When that thread detaches, it will be
removed. Once the thread is attached, if a client is debugging, the
client can use the `CMD_THREAD_GET_FRAME_INFO` command to ask for
details about that thread.

This is a possibility that the thread detaches before the
`CMD_THREAD_GET_FRAME_INFO` command is processed, so the thread may not
exist the the `thread_to_tls` hash table any more.

This is a race condition, but is a valid state, so instead of asserting,
the debugger agent should indicate to the client that the thread no
longer exists, using `ERR_UNLOADED`.
src/mono/mono/mini/debugger-agent.c