[coop handles] Add some memory fences (#3617)
authorAleksey Kliger (λgeek) <akliger@gmail.com>
Tue, 27 Sep 2016 21:02:18 +0000 (17:02 -0400)
committerGitHub <noreply@github.com>
Tue, 27 Sep 2016 21:02:18 +0000 (17:02 -0400)
commit76b32f3ee38e7b29cdbaa657a4826b65579f4e93
treeb0c66fef849ad2e039e406ef708c02e0a388cfed
parentfd6108736c215244d2a5ed64f11e1876295cbd87
[coop handles] Add some memory fences (#3617)

When running with async suspend (ie, not coop), a user thread might be
suspended while its manipulating the coop handle stack.  In that case,
we want to present a consitent view to mono_handle_stack_scan () by
adding memory fences to code that updates the stack chunks.  In
particular we want to ensure that the chunk size is increased after
the new slot has a valid (null) value.  Also when creating new chunks
make sure their size is initialized before the chunk stack is updated.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=43921 (at least the
one stack trace observed in [comment 1](https://bugzilla.xamarin.com/show_bug.cgi?id=43921#c1)).
mono/metadata/handle.c
mono/metadata/handle.h