[runtime] Don't start aborting a thread if it's running any .cctor. Fixes #43320.
authorRodrigo Kumpera <kumpera@gmail.com>
Thu, 25 Aug 2016 23:39:50 +0000 (16:39 -0700)
committerRodrigo Kumpera <kumpera@gmail.com>
Thu, 1 Sep 2016 00:45:31 +0000 (17:45 -0700)
commit152a3943ae42603e86d9406a3adacda509b415fd
treebcdb01c39cdaab28a1517d21ba3165651ca1e893
parent48d1f5cd094b456e076d46ecf76591c7da55c037
[runtime] Don't start aborting a thread if it's running any .cctor. Fixes #43320.

A thread abort must not start if the thread is running a .cctor.
OTOH, if the cctor self aborts, it should start.

Threads now track how many cctors they are running in the cctor_exec_depth variable.

The abort machinery (in async_abort_critical) checks that flag and bail from
starting the abort.

The cctor code (in mono_runtime_class_init_full) ensures that cctor_exec_depth is bumped
around execution of the cctor itself. Additionally, error handling was cleaned up as it was pretty
inconsistent.
mono/metadata/object-internals.h
mono/metadata/object.c
mono/metadata/threads.c