 following classes:
<code>
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;
}
}
</code>
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:
mono-rt:
Native stacktrace:
mono-rt:
=================================================================
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)
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.
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.
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
It's compiler issue the generated code is not strictly valid
Marek,
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.
The fix will show up in mono release made after the commit which resolves the issue lands in master.
Fixed in master
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
Runtime:
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
Xamarin.Mac: Not Installed
Xamarin.iOS
Version: 7.2.1.42 (Business Edition)
Hash: 773c77c
Branch:
Build date: 2014-04-18 15:39:16-0400
Xamarin.Android
Version: 4.12.3 (Business Edition)
Android SDK: /Users/taken
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.
@Guilherme: can you try installing the latest Mono alpha (3.4.0)?