Bug 13149 - Crash in RuntimeReflectionExtensions.GetRuntimeMethod
Summary: Crash in RuntimeReflectionExtensions.GetRuntimeMethod
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 4.7.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Martin Baulig
URL:
Depends on:
Blocks:
 
Reported: 2013-07-10 12:13 UTC by MikeFayer
Modified: 2014-07-28 18:10 UTC (History)
8 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Zipped VS solution containing a reproduction. (25.61 KB, application/zip)
2013-07-10 12:13 UTC, MikeFayer
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description MikeFayer 2013-07-10 12:13:57 UTC
Created attachment 4304 [details]
Zipped VS solution containing a reproduction.

GetRunTimeMethod in RuntimeReflectionExtions when used from a Profile78 PCL crashes the app when run from a debugger, and freezes when run without the debugger.
Comment 1 mera 2013-07-29 11:17:15 UTC
It seems to produce a stackoverflow exception. Every method in RuntimeReflectionExtensions looks like this:

public static IEnumerable<PropertyInfo> GetRuntimeProperties (this Type type)
{
    return type.GetRuntimeProperties ();
}


Which obviously produces a stackoverflow exception. It is very easy to reproduce with any kind of those methods.
Comment 2 mera 2013-07-30 07:24:27 UTC
What about this solution:


private IEnumerable<PropertyInfo> GetAllProperties(Type type)
{
    var properties = type.GetTypeInfo().DeclaredProperties.ToList();

    var baseType = type.GetTypeInfo().BaseType;
    if (baseType != typeof (object))
    {
        var baseProperties = GetAllProperties(baseType);
        properties.AddRange(baseProperties);
    }

    return properties;
}
Comment 3 mera 2013-08-02 05:14:39 UTC
The above workaround works well but when it comes to use the overloaded method GetMethodInfo(Delegate) it still produces a stackoverflow. 

E.g. try to call GetMethodInfo on an Action

This is really a serious bug which affects many usages. Could anyone please comment on that when it's gonna be fixed? In this state we cannot work anymore.
Comment 4 troy-dawson 2013-08-10 17:29:51 UTC
Ran into this issue calling:

			var info = engine.update2.GetMethodInfo();

where update2 is:

		public Action<float> update2;

		public Engine()
		{
			sfx = new Dictionary<string, SoundEffect>();

			InitData();

			LoadStorage();

			update2 = NoUpdate;
		}

		void NoUpdate(float update_dt)
		{
		}
Comment 5 softlion 2013-11-12 10:31:35 UTC
RuntimeReflectionExtension.GetRuntimeMethod returns nothing in latest Xamarin version. It seems that the PCL bindings are not implemented at all.

The PCL compiles fine, but when used from monodroid it returns an empty list.

.GetTypeInfo().DeclaredMethods don't work either.

Using Profile49.
Comment 6 Nate Rickard 2013-11-27 14:31:55 UTC
I can confirm this is happening using PCL Profile49 as well, GetRuntimeMethod() and GetRuntimeMethods() both return null.  I've worked around it by using type.GetTypeInfo ().GetDeclaredMethod (methodName);

Running Alpha channel: Studio v 4.3.0, Xamarin.iOS v 7.0.4.209
Comment 7 Jonathan Pryor 2014-07-28 18:10:50 UTC
Should be fixed in Xamarin.Android 4.14 (or earlier?).