Bug 4039 - crash when calling a generic virtual method defined in base class from ctor
Summary: crash when calling a generic virtual method defined in base class from ctor
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 5.2
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-03-22 16:55 UTC by Chris Toshok
Modified: 2012-03-23 10:21 UTC (History)
3 users (show)

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

AppDelegate.cs file (1.58 KB, text/plain)
2012-03-22 16:56 UTC, Chris Toshok
sdb-related crash report (23.03 KB, text/plain)
2012-03-22 18:46 UTC, Rolf Bjarne Kvinge [MSFT]
aot crash report with llvm (14.06 KB, text/plain)
2012-03-22 18:48 UTC, Rolf Bjarne Kvinge [MSFT]

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:

Description Chris Toshok 2012-03-22 16:55:51 UTC
Create a normal monotouch project and replace the AppDelegate.cs file with the attached file.

the app exits with no stack trace after printing "before".

this pattern is used in a large monotouch app and in that instance, the method called is some other method in another type that is in no way related to the code (it's consistently the same method, across runs and recompiles).

a couple of changes fix the crash:

1) if you change SetList from virtual to non-virtual, no crash.
2) if you change CrashyBaseType to a non-generic class (replacing TModel with int), no crash.
Comment 1 Chris Toshok 2012-03-22 16:56:29 UTC
Created attachment 1556 [details]
AppDelegate.cs file
Comment 2 Rolf Bjarne Kvinge [MSFT] 2012-03-22 18:44:41 UTC
* Simulator works fine.

* Device seems to have a somewhat random behavior:
  1) It doesn't crash (but "hi" is never printed)
  2) If I put a breakpoint on "Console.WriteLine ("hi");", it breaks on the call to SetList in UpdateView.
  3) I also once got a crash which seems related to sdb, see attached crash report.
  4) Enabling LLVM makes the aot-compiler crash instead.
Comment 3 Rolf Bjarne Kvinge [MSFT] 2012-03-22 18:46:07 UTC
Created attachment 1558 [details]
sdb-related crash report
Comment 4 Rolf Bjarne Kvinge [MSFT] 2012-03-22 18:48:11 UTC
Created attachment 1559 [details]
aot crash report with llvm
Comment 5 Rolf Bjarne Kvinge [MSFT] 2012-03-22 18:48:49 UTC
Zoltan, it looks like this is related to the aot-compiler somehow, can you have a look?
Comment 6 Zoltan Varga 2012-03-22 22:02:53 UTC
Rofl: what version are you using ? There was a LLVM crash caused by the direct icall changes, which have since been fixed in master.
Comment 7 Zoltan Varga 2012-03-22 22:41:20 UTC
The crash happens because UpdateView () seems to recursively call CrashySubType:.ctor () because of a runtime problem.
Comment 8 Zoltan Varga 2012-03-23 00:07:40 UTC
This was already fixed in mono master, but the fix somehow didn't made it to mobile-master. Now it should be there.
As for the LLVM crash, I can't reproduce that.
Comment 9 Zoltan Varga 2012-03-23 00:08:14 UTC
The commit is e6e0e67b92ef56b4f852021fde4e40c27891ca6f.
Comment 10 Rolf Bjarne Kvinge [MSFT] 2012-03-23 10:21:06 UTC
Confirmed fixed in e5f84b3fe (master) and b566eb93 (5.2-series).

It will be included in 5.2.11 and 5.3.3.