Do not access unloading domains in debugger (case 1013579) (#19322)
commit0565f6e2c0e1e15f490ab0e7d4005d0e36abaa29
authormonojenkins <jo.shields+jenkins@xamarin.com>
Thu, 26 Mar 2020 20:38:26 +0000 (26 16:38 -0400)
committerGitHub <noreply@github.com>
Thu, 26 Mar 2020 20:38:26 +0000 (26 16:38 -0400)
tree008fda1e270c3a217cb6714f41248a6f19201ee7
parentb7196c45e8643217cffdcba5f373c7918d505973
Do not access unloading domains in debugger (case 1013579) (#19322)

There was a race where a domain was being unloaded while debugger would access it. A domain was only removed from the 'appdomains_list' as a very last step. The domain was already invalid to access at this point (locks freed for example).

Worse, images would be unloaded if only referenced by that domain. All places the debugger iterates domains hold the loader lock. The loader lock is acquired by the domain unloading process, so as long as a domain is not unloading when we access it inside of the loader lock we are safe.

include domain unloading check in collect_domain_bp

Co-authored-by: Jonathan Chambers <joncham@gmail.com>
mono/mini/debugger-agent.c
mono/mini/debugger-engine.c