Merge pull request #2881 from alexrp/gc-sample-managed-alloc
authormonojenkins <jo.shields+jenkins@xamarin.com>
Thu, 2 Jun 2016 20:45:26 +0000 (21:45 +0100)
committermonojenkins <jo.shields+jenkins@xamarin.com>
Thu, 2 Jun 2016 20:45:26 +0000 (21:45 +0100)
commitf1dd6fe7488b0de7fdd8beda7cf3a15cd4f9bce2
tree492bba0d230e9bb50297205127878299b5b0e384
parentb2cf10659d74681988ad53c18f368c007990d829
parentf9ef2ce1222358090dea0f330cdf07b82b72b628
Merge pull request #2881 from alexrp/gc-sample-managed-alloc

[gc] Register a critical region when executing managed allocators.

Previously, if we stopped a thread and it had a stack looking like this:

    ...
    profiler_signal_handler
    <signal handler called>
    managed_allocator
    ...

We would fail to identify the fact that we've just interrupted a thread that's
in a managed allocator (uninterruptible code) because we only look at the very
latest instruction pointer of the thread, which will be pointing into
profiler_signal_handler or some other function called by it. So we would
happily continue along with the STW process and proceed to doing the actual GC,
where we would see a broken heap.

We could solve this by unwinding the stack and checking all frames, but that's
complicated and error-prone. Instead, register a critical region while the
managed allocator runs. This way, if we don't identify it by instruction pointer, we
will identify it by the fact that the thread is in a critical region.
mono/mini/aot-compiler.c
mono/mini/aot-runtime.c
mono/mini/mini-arm.c