[runtime] Fix bug in get_caller_no_reflection
authorAleksey Kliger <aleksey@xamarin.com>
Tue, 5 Apr 2016 19:24:23 +0000 (15:24 -0400)
committerAleksey Kliger <aleksey@xamarin.com>
Wed, 6 Apr 2016 17:56:08 +0000 (13:56 -0400)
commit9be882ab60747e5f26acd4734df103affb6beb59
treeddfd3c4bb8e087c3c359579d2085665b07b601eb
parent45d03ae47d8c5367fa76e41b8acb1ed2808771bd
[runtime] Fix bug in get_caller_no_reflection

In order to find the user code that called some corlib API
that calls an icall, we write:
dest = m = mono_method_get_last_managed ();
mono_stack_walk_no_il (get_caller_no_reflection, &dest);
if (!dest) dest = m;

The get_caller_no_reflection walk works in two stages: in the first
stage we look for the target method (the initial value of dest) when we
find the target we set dest to NULL and then the second stage continues
walking upward past the reflection APIs.

However if the target method is itself in System.Reflection, the
old implementation would skip over it even in the first stage and we'd
never find the target method and exhaust the whole stack.

The fix is to move the check for the target method before the check for
the Reflection API methods.
mono/metadata/icall.c