[threads] Fix reset blocking state transition
commit2653868a2731c2282628472587e01460dd71cc2f
authorLudovic Henry <ludovic@xamarin.com>
Mon, 9 May 2016 22:32:50 +0000 (9 18:32 -0400)
committerLudovic Henry <ludovic@xamarin.com>
Mon, 9 May 2016 23:10:43 +0000 (9 19:10 -0400)
tree10d0315cdd77b479e6dd198b3bf31cad57f6fa66
parent65ab352de4d4818baa4b167a1bbb0c45e0062c99
[threads] Fix reset blocking state transition

There would previously be a race between reset blocking and a STW, that would happen as follow:
 - T1 goes into blocking - T1 state is BLOCKING(0)
 - T2 suspends T1  - T1 state is BLOCKING(1)
 - T1 does a reset blocking -> T1 state is SELF SUSPEND REQUESTED
 - T2 calls `mono_thread_info_get_suspend_state` on T1 --- SIGABRT as we cannot get suspend state when state is SELF SUSPEND REQUESTED
 - T1 does polling -> T1 state is SELF SUSPENDED

The fix is for reset blocking to work like done blocking: switch to BLOCKING AND SUSPENDED.
mono/utils/mono-threads-coop.c
mono/utils/mono-threads-state-machine.c
mono/utils/mono-threads.h