Bug 16806 - async & inheritance method call crash
Summary: async & inheritance method call crash
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
Depends on:
Reported: 2013-12-15 14:28 UTC by Cristoph
Modified: 2014-05-05 11:57 UTC (History)
5 users (show)

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

Just start app and press: Get Async (1.44 MB, application/zip)
2013-12-16 12:16 UTC, Cristoph

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:

Description Cristoph 2013-12-15 14:28:51 UTC
I have following classes:
public class Car
		public Car ()
		string engineName="baseEngine";
		int age=5;
		public async Task<string> GetEngineName()
			return engineName;
		public int GetAge()
			return this.age;
	public class Ford:Car
		public Ford ():base()

		public async new Task<string> GetEngineName()
			int engineAge = this.GetAge ();//value returned is 5 as it should
			int engineAgeBase = base.GetAge (); // value returned is 0-wrong!

			string engineName= await base.GetEngineName();//here it crashes
			return engineName;

When I call:

Ford ford=new Ford();
await ford.GetEngineName();

There are 2 bugs(probably related):
1.engineAgeBase has value=0 and should have 5, also to notice that all variables initialized in ctor lost its values when is called base.Method(), it's very wired seems like 'this' and 'base' are 2 different instances.
2.When it is called string engineName= await base.GetEngineName(); it crashes with:
"mono-rt: Stacktrace:
Native stacktrace:
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.

Just FYI: this is just a simplified example, example has no meaning, but this issue occur in real scenario(I'm trying to port a lib from .NET/WP/WinStore on Xamarin and I got that issues)
Comment 1 Rolf Bjarne Kvinge [MSFT] 2013-12-16 09:27:26 UTC
I tried pasting your code into a test project and it ran fine for me.

Can you create a complete test project that fails for you? The project settings can sometimes be significant, and in addition ensures we're doing the exact same thing as you are.
Comment 2 Cristoph 2013-12-16 12:16:21 UTC
Created attachment 5671 [details]
Just start app and press: Get Async

Just press 'Get Async' and you will see the crash.
If you put break points in Xamarin Studio you will see that base.GetAge() returns 0.
Comment 3 Cristoph 2013-12-16 12:19:17 UTC
Just as extra info: I'm using latest stable version of Xamarin.iOS, Xamarin.Android and Xamarin Studio and running it on OSX 10.8.5
Comment 4 Marek Safar 2013-12-16 12:20:40 UTC
It's compiler issue the generated code is not strictly valid
Comment 5 Cristoph 2013-12-17 16:34:24 UTC
any idea if the fix will come on Stable version or Alpha/Beta first? I'm not aware of your flow and would be very important for me to know where should I expect the fix.
Comment 6 Marek Safar 2013-12-17 16:56:40 UTC
The fix will show up in mono release made after the commit which resolves the issue lands in master.
Comment 7 Marek Safar 2014-01-04 09:34:09 UTC
Fixed in master
Comment 8 Guilherme Torres Castro 2014-05-05 10:59:05 UTC
I just update the to the version below, and my code that was working started to crash.

Xamarin Studio
Version 4.2.4 (build 35)
Installation UUID: ae226d65-a362-4c5d-a9b1-26f389a71bb8
	Mono 3.2.6 ((no/9b58377)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 302060000

Apple Developer Tools
Xcode 5.1.1 (5085)
Build 5B1008

Xamarin.Mac: Not Installed

Version: (Business Edition)
Hash: 773c77c
Build date: 2014-04-18 15:39:16-0400

Version: 4.12.3 (Business Edition)
Android SDK: /Users/takenet/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		4.0   (API level 14)
		4.0.3 (API level 15)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

Build Information
Release ID: 402040035
Git revision: 1173cb1c45bc56cb702e82cd21a7c9d0cea4acbf
Build date: 2014-04-17 13:45:52-04
Xamarin addins: 53bde0041263928e8bd64686f5ca5a8e4338dd76

Operating System
Mac OS X 10.9.2
Darwin MacBook-Pro-de-Takenet.local 13.1.0 Darwin Kernel Version 13.1.0
    Wed Apr  2 23:52:02 PDT 2014
    root:xnu-2422.92.1~2/RELEASE_X86_64 x86_64

I removed the base method, had to copy and paste it on a lot of classes, and them the crash stop.

Probably this version got a BUG regression.
Comment 9 Rolf Bjarne Kvinge [MSFT] 2014-05-05 11:57:52 UTC
@Guilherme: can you try installing the latest Mono alpha (3.4.0)?