[w32handle] Fix race in foreach and unref (#4089)
authorLudovic Henry <ludovic@xamarin.com>
Tue, 6 Dec 2016 14:49:32 +0000 (09:49 -0500)
committerGitHub <noreply@github.com>
Tue, 6 Dec 2016 14:49:32 +0000 (09:49 -0500)
commitde21ecd34ff7729ea35c8f49780346a35a52a6f4
tree461a9649e4b4ba0ba5829c6130843dbe06dd7631
parent06088609b0ee50af41e59e7366100e25d55a9130
[w32handle] Fix race in foreach and unref (#4089)

It could happen that we unref a handle that we are currently looping over. This could be the case if we are calling Process.GetProcessById (which loops over all handles) and mono_w32handle_unref on a MonoW32HandleProcess handle.
mono/metadata/w32handle.c
mono/tests/Makefile.am
mono/tests/process-unref-race.cs [new file with mode: 0644]