[threads] Delay abort via handler block guard when in abort protected block.
commit92042c97323dfe688fac085f322088beb11383cc
authorAleksey Kliger <alklig@microsoft.com>
Tue, 13 Mar 2018 19:30:27 +0000 (13 15:30 -0400)
committerAleksey Kliger <alklig@microsoft.com>
Fri, 16 Mar 2018 15:54:45 +0000 (16 11:54 -0400)
tree362b1b509c852b30a8464ae074d1b9440ca8b6b3
parentb0734593de5ba1e2e97255ee08500124bd6f7786
[threads] Delay abort via handler block guard when in abort protected block.

mono_install_handler_block_guard is called when we want to signal an async
abort to another thread.  In case the other thread is executing native code
while in a `finally` block, the handler block guard sets a byte in the finally
block that used to trigger a self abort (`mono_thread_self_abort`).

This PR renames `mono_thread_self_abort` to
`ves_icall_thread_finish_async_abort`.  It also changes the code from
immediately executing a synchronous abort, to checking whether we are in an
abort protected block (most commonly - whether we were called from a cctor) and
in that case merely toggling the "async interrupt"
MonoInternalThread:thread_state bit.  If we're not in an abort-protected block,
trigger a self interrupt (which will turn into an abort exception in the
icall wrapper of `ves_icall_thread_finish_async_abort`).
mono/metadata/threads-types.h
mono/metadata/threads.c
mono/mini/method-to-ir.c
mono/mini/mini-runtime.c