[runtime] Rework abort deferring
authorVlad Brezae <brezaevlad@gmail.com>
Fri, 17 Mar 2017 13:05:10 +0000 (15:05 +0200)
committerVlad Brezae <brezaevlad@gmail.com>
Wed, 22 Mar 2017 23:40:02 +0000 (01:40 +0200)
commit786cbe76a82cc31f8047765be974701b754d2cde
treea369f9058461ff7b6da4c7136fba15dc4a6afba9
parent1592e1e3dae827bcfa301d234f7316ab0c9f975f
[runtime] Rework abort deferring

The problem with previous implementation was that we were not able to account for two pending exceptions at the same time, since when we execute an interruption request we clear all the state and there is no clear way to account for two exceptions at the same time. This means that, if we have a pending abort in a cctor, all exception handling inside the cctor will be broken (for the provided test case we were only throwing the cctor internal exception outside of it).

In order to fix this, we split into two types of interruptions SYNC and ASYNC (in order to separate mainly between abort and pending exceptions). Sync interruptions are interruptions requested by the thread itself (pending exceptions and self aborts) and they are processed as soon as possible. Async interruptions are requested by other threads (abort, interrupt, suspend) and we defer them as we were doing before (we have a deferred interruption if we have an async exception and abort block count is non zero).
mono/metadata/threads.c
mono/tests/abort-cctor-2.cs [new file with mode: 0644]
mono/tests/abort-cctor.cs