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)
[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.

1  2 
mono/mini/aot-compiler.c
mono/mini/aot-runtime.c
mono/mini/mini-arm.c

Simple merge
Simple merge
Simple merge