Bug 622 - Compiler crashes when default value supplied for decimal method parameter
Summary: Compiler crashes when default value supplied for decimal method parameter
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools ()
Version: 4.x
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: 6.4 (async)
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-09-03 23:59 UTC by competent_tech
Modified: 2013-05-01 10:32 UTC (History)
8 users (show)

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

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:
VERIFIED FIXED

Description competent_tech 2011-09-03 23:59:24 UTC
The following class alone in a project:

using System;

namespace Test
{
    public class TestClass
    {
        public TestClass ()
        {
        }
        public static decimal DecimalFromDB(object theValue, decimal dDefaultValue = 0)
        {
            return dDefaultValue;
        }

    }
} 

will cause the compiler to crash. Removing the default value for dDefaultValue fixes the problem. 

Here is the crash report that is generated:

Performing main compilation...
/Developer/MonoTouch/usr/bin/smcs /noconfig "/out:/Users/Karl/Projects/CTIMono/Common/SystemFramework/bin/iPhoneSimulator/Debug/CTI.Common.SystemFramework.Mono.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/System.Data.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/System.Runtime.Serialization.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/mscorlib.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/System.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll" /nologo /warn:1 /debug:+ /debug:full /optimize- /codepage:utf8 "/define:DEBUG;Mono"  /t:library
[[file names removed here]]
we can't encode valuetypes, we should have never reached this line

Stacktrace:

  at (wrapper managed-to-native) System.Reflection.Emit.TypeBuilder.create_runtime_class (System.Reflection.Emit.TypeBuilder,System.Reflection.Emit.TypeBuilder) <0xffffffff>
  at System.Reflection.Emit.TypeBuilder.CreateType () <0x003a3>
  at Mono.CSharp.TypeContainer.CloseType () <0x0019b>
  at Mono.CSharp.ModuleContainer.CloseType () <0x00080>
  at Mono.CSharp.Driver.Compile () <0x0047c>
  at Mono.CSharp.Driver.Main (string[]) <0x000ab>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_int_object (object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

        0   mono                                0x000d533a 0x0 + 873274
        1   mono                                0x001385ba 0x0 + 1279418

Debug info from gdb:

/tmp/mono-gdb-commands.41xvFf:1: Error in sourced command file:
unable to debug self

=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================

/Developer/MonoTouch/usr/bin/smcs: line 2:   462 Abort trap              MONO_PATH=/Developer/MonoTouch/usr/lib/mono/2.1 /Developer/MonoTouch/usr/bin/mono /Developer/MonoTouch/usr/lib/mono/2.1/smcs.exe "$@"


Stacktrace:

  at (wrapper managed-to-native) System.Reflection.Emit.TypeBuilder.create_runtime_class (System.Reflection.Emit.TypeBuilder,System.Reflection.Emit.TypeBuilder) <0xffffffff>
  at System.Reflection.Emit.TypeBuilder.CreateType () <0x003a3>
  at Mono.CSharp.TypeContainer.CloseType () <0x0019b>
  at Mono.CSharp.ModuleContainer.CloseType () <0x00080>
  at Mono.CSharp.Driver.Compile () <0x0047c>
  at Mono.CSharp.Driver.Main (string[]) <0x000ab>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_int_object (object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

        0   mono                                0x000d533a 0x0 + 873274
        1   mono                                0x001385ba 0x0 + 1279418

Debug info from gdb:

/tmp/mono-gdb-commands.41xvFf:1: Error in sourced command file:
unable to debug self

=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================

/Developer/MonoTouch/usr/bin/smcs: line 2:   462 Abort trap              MONO_PATH=/Developer/MonoTouch/usr/lib/mono/2.1 /Developer/MonoTouch/usr/bin/mono /Developer/MonoTouch/usr/lib/mono/2.1/smcs.exe "$@"
Build complete -- 1 error, 0 warnings

---------------------- Done ----------------------

Build: 1 error, 0 warnings
Comment 1 Jeffrey Stedfast 2011-09-06 10:30:04 UTC
Note for whoever ends up looking into this bug:

As Nic Wise points out on the mailing-list:


--------------------------------------------------------
Interestingly, this works

public static decimal DecimalFromDB(object theValue, decimal
dDefaultValue = Decimal.Zero)

Problem converting for (int)0 to (decimal)0??
--------------------------------------------------------
Comment 2 Marek Safar 2011-09-06 10:41:49 UTC
This has been already fixed in mono master. I vaguely remember fixing bugs related to this some time ago (6months?) and reporting bug for runtime too.

This is not easy to back-port especially now when mcs does not use SRE.
Comment 3 Jeffrey Stedfast 2011-09-06 11:38:45 UTC
Thanks for the info, Marek.

I guess this'll be fixed in MonoTouch once we update to Mono 2.11 or 2.12

I'm going to reopen and set the product to MonoTouch as that's where this belongs if the problem is fixed in Mono master.


computer_tech: Can you use Nic Wise's workaround until MonoTouch is updated to use Mono 2.12? It'll probably be a while before that happens, unfortunately, because that will be a pretty large change.
Comment 4 Mark Foley 2012-12-11 17:53:58 UTC
I experienced this a few days ago on the latest stable release of MT - so perhaps this fix hasn't made it through?
Comment 5 Rolf Bjarne Kvinge [MSFT] 2012-12-11 18:17:52 UTC
Mark, MonoTouch hasn't been updated to use Mono 3.0 yet (Mono 2.12 was renamed to 3.0 recently).
Comment 6 Mark Foley 2012-12-11 18:20:38 UTC
Ah.  It's not a major one.  Is that update planned?  I hadn't realised MT was behind the main Mono releases.
Comment 7 PJ 2013-04-23 14:17:18 UTC
Stable support for mono 3.0 will be landing in the 6.4 Xamarin.iOS. Changing to this milestone.
Comment 8 Rolf Bjarne Kvinge [MSFT] 2013-04-24 17:27:24 UTC
This is fixed in 6.3.4 (and probably since the first 6.3 release).
Comment 9 Saurabh 2013-05-01 07:16:37 UTC
Today we have checked this issue with following builds:

X.S 4.1.1(build 49)
Mono 3.0.11 ((no/edc181c)
Xamarin.iOS 6.3.5.1

And we have created a empty class in our project and the pasted the code in that class. When we run/debug the application it deployed and launched successfully. Application does not crash. Please let us know have we followed correct steps to verify this issue?
Comment 10 Rolf Bjarne Kvinge [MSFT] 2013-05-01 07:24:37 UTC
Yes, you followed the correct steps.