Bug 8004 - Runtime Regression and Generics
Summary: Runtime Regression and Generics
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: General ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Zoltan Varga
URL:
Depends on:
Blocks:
 
Reported: 2012-10-25 17:02 UTC by Andrew Way
Modified: 2017-08-28 15:04 UTC (History)
8 users (show)

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


Attachments
Stacktraces (37.74 KB, text/plain)
2012-10-25 17:02 UTC, Andrew Way
Details
Sourcecode (5.14 KB, application/zip)
2012-10-25 17:04 UTC, Andrew Way
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 GitHub or Developer Community 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 Andrew Way 2012-10-25 17:02:57 UTC
Created attachment 2796 [details]
Stacktraces

On behalf of jourke@appmachine.com
-----
Jourke de Boer writes : 

I tried to create a project that reproduces the problem, but wasn't succesful. During the testing against the full app I did figure out what goes wrong and how to reproduce it consistently.

In the mono/mini/aot_compiler.c a change was made to set the pointer info for the trampoline. (https://github.com/mono/mono/commit/2a63257bf810ddfdb9a1e36a4f899d1ae599d558#mono/mini/aot-runtime.c)

The ptr setting was changed from method (and default klass) to a method/klass or other. 
This change seems to affect the pointer tables kept internally. BTW: This is not the only place where this change is made, but the effect is the same.
If an interface (or and abstract class as in the 7457 case) with a generic parameter is used (i;e; IMyInterface<T> : ISomeOtherInterface), the table is corrupted.

The third or fourth time this info is used, I vrified this by running a fixed path in our platform which does this. It now reproduces the error consistently.
I reproduced this in a sample app, but the table corruption only appears with enough other type info in the app. So the sample app is too simple to reprodue the error.

The main generator for this kind of interfaces is based on an open source app (https://github.com/Redth/MonoTouch.UrlImageStore). Maybe you can combine my code or a sample app for this. I got sidetracked by a major issue, so I didn't have the time to finish the testing :-)

I attached a few stacktraces from the main app (AppstraDev) and  the sourcecode. If you pass this information on, you should be able to tackle this problem. If get the same issue reproducable in my testapp, I'll attach it to the bugreport. This is still registered as fixed by the way.

Anyway, let me know if I can test hotfixes or provide you with more information.
Comment 1 Andrew Way 2012-10-25 17:04:06 UTC
Created attachment 2797 [details]
Sourcecode

submitted on behalf of jourke@appmachine.com
Comment 2 Zoltan Varga 2012-10-25 17:20:15 UTC
 Try adding
-aot "ntrampolines=2048"
to the 'Additional mtouch arguments' field in the 'iphone build' tab in project options.
Comment 3 Andrew Way 2012-10-25 17:24:38 UTC
For more background, please refer to this discussion: http://monotouch.2284126.n4.nabble.com/Understanding-the-impact-of-trampolines-td4495086.html
Comment 4 jouke 2012-10-26 03:37:12 UTC
The settings were: --nolinkaway --aot "ntrampolines=4096" --aot "nimt-trampolines=512"

I don't think that this setting is related however. Issues with running out of trampolines will result in "out of trampolines of type 0/2" messages and are quite consistent. I've run into those before.
Comment 5 Zoltan Varga 2012-10-26 08:03:42 UTC
Looking at the stack traces, this seems like running out of trampolines, but for some reason, the message is not printed out. Could you try increasing the number of trampolines even further, and see whenever that makes any difference ?
Comment 6 Zoltan Varga 2012-10-26 11:30:48 UTC
About the commit you mentioned, that commit is only in mono master, and not in monotouch.
Comment 7 Andrew Way 2012-10-26 12:36:07 UTC
CORRECTION:  

jourke@appmachine.com --> jouke@appmachine.com
Comment 8 jouke 2012-10-31 05:10:30 UTC
Increasing the trampolines did help. The testbuild removed the setting (mistake on my side) so it defaulted back to 512. It is now a lot harder to produce the error.

So as a workaround this works. New code already minimizes use of generics since using more than 3 generic parameters (rule of thumb) will cause runtime errors on the device or running out of trampolines. These two actions make this work for us for now. It takes the sting out of the error.

The commit was in the mono/mini branch (unless I misread it). I thought this implied that it was included in the base of monotouch. Deducing the error from that changeset produced the testcase so it could be reproduced easily and consitently. But it is all based on guessing how your code works from my standpoint.
Comment 10 Zoltan Varga 2012-11-02 15:10:19 UTC
I couldn't reproduce this using the provided testcase.
Comment 11 Rodrigo Kumpera 2013-08-23 14:30:48 UTC
Monotouch stable doesn't suffer from this limitation anymore.