Bug 13753 - Error: Compiler crashed with code: 1
Summary: Error: Compiler crashed with code: 1
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2013-08-05 11:48 UTC by Jens
Modified: 2013-08-05 13:50 UTC (History)
2 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 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 Jens 2013-08-05 11:48:25 UTC
I currently get a "Error: Compiler crashed with code: 1" when I try to compile my current app and I have no idea what to do about it :(

for a fast look you can look at http://pastebin.com/YV9z66wQ for some diagnosis during the compile

I will attach the app to this bug so you can dig deeper into it.

Comment: in the console app Prepare.Database (it is pretty small so far) this problem happens when I link the file "CoreShared->src->DataClasses->MatchData->FormOfSports.cs" to the project. When that file is not part of the project it compiles fine
Comment 2 Jens 2013-08-05 12:20:20 UTC
as jonp found out:
the problem is in the code after line 44 of "CoreShared->src->DataClasses->MatchData->FormOfSports.cs":

formOfSport = formOfSportList.Find (sport => {
   sport.id == id;
});

probably a bug in my code, but the compiler should show it instead of crashing...
Comment 3 Jonathan Pryor 2013-08-05 12:26:46 UTC
Minimal test case:

  using System;
  using System.Collections.Generic;

  public class FormOfSport {
    public int id { get; set;}
  }

  public class FormOfSportList {

    private static List<FormOfSport> formOfSportList;

    public static FormOfSport GetFormOfSportById (int id) {
      FormOfSport formOfSport = null;

      formOfSport = formOfSportList.Find (sport => {
        sport.id == id;
      });

      return formOfSport;
    }

    public static void Main ()
    {
    }
  }

Compilation:

    $ mcs src/DataClasses/MatchData/FormOfSportList.cs 
    Compilation failed: 1 error(s), 0 warnings

Hm, not quite handy; more info:

> $ mcs src/DataClasses/MatchData/FormOfSportList.cs  --stacktrace
> 	in Expression.Resolve (Mono.CSharp.ResolveContext, Mono.CSharp.ResolveFlags)
> 	in Expression.Resolve (Mono.CSharp.ResolveContext)
> 	in Assign.DoResolve (Mono.CSharp.ResolveContext)
> 	in SimpleAssign.DoResolve (Mono.CSharp.ResolveContext)
> 	in Expression.Resolve (Mono.CSharp.ResolveContext, Mono.CSharp.ResolveFlags)
> 	in Expression.Resolve (Mono.CSharp.ResolveContext)
> 	in ExpressionStatement.ResolveStatement (Mono.CSharp.BlockContext)
> 	in StatementExpression.Resolve (Mono.CSharp.BlockContext)
> 	in Block.Resolve (Mono.CSharp.BlockContext)
> 	in ParametersBlock.Resolve (Mono.CSharp.FlowBranching, Mono.CSharp.BlockContext, Mono.CSharp.IMethodData)
> 	in MethodData.Emit (Mono.CSharp.TypeDefinition)
> 	in MethodOrOperator.Emit ()
> 	in Method.Emit ()
> 	in TypeDefinition.Emit ()
> 	in ClassOrStruct.Emit ()
> 	in Class.Emit ()
> 	in TypeDefinition.EmitContainer ()
> 	in TypeContainer.EmitContainer ()
> 	in NamespaceContainer.EmitContainer ()
> 	in TypeContainer.EmitContainer ()
> 	in ModuleContainer.EmitContainer ()
> 	in AssemblyDefinition.Emit ()
> 	in AssemblyDefinitionStatic.Emit ()
> 	in Driver.Compile ()
> 	in Driver.Main (System.String[])
> 
> Compilation failed: 1 error(s), 0 warnings

Seen with version:

$ mono --version
Mono JIT compiler version 3.2.0 ((no/7c7fcc7 Tue Jul 23 19:59:39 EDT 2013)
Comment 4 Jonathan Pryor 2013-08-05 12:28:24 UTC
> probably a bug in my code

Indeed, the problem is that the delegate provided to List<T>.Find(Predicate<T>) is missing a `return` keyword; it _should_ be:

     formOfSport = formOfSportList.Find (sport => {
        return sport.id == id;
     });

That said, as Jens pointed out this shouldn't result in a compiler crash.
Comment 5 Marek Safar 2013-08-05 13:43:15 UTC
Already fixed in Mono master. The code reports

1.cs(16,15): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
1.cs(15,43): error CS1643: Not all code paths return a value in anonymous method of type `System.Predicate<FormOfSport>'
Comment 6 Jens 2013-08-05 13:50:08 UTC
cool, nice to hear :)