dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.92k stars 4.02k forks source link

vbc crashes on RELEASE Build (error MSB6006: "vbc.exe" exited with code -2146232797) #7144

Closed christopherstamm closed 8 years ago

christopherstamm commented 8 years ago

Hello, i just updated to VS2015 Update1.

Now one of my Projects crashes on RELEASE build DEBUG compile runs fine. on VS 2013 or VS2015 without Update it compiles without issue. Targetframework is .net3.5 Language is VB

Build

  "C:\Program Files (x86)\MSBuild\14.0\bin\vbc.exe" /noconfig /imports:Microsoft.VisualBasic,System,System.Collections,System.Collections.Generic,System.Data,System.Diagnostics,System.Linq,System.Xml.Linq /optioncompare:Binary /optionexplicit+ /optionstrict+ /optioninfer+ /nostdlib /rootnamespace:AppName /sdkpath:"C:\Windows\Microsoft.NET\Framework\v2.0.50727" /preferreduilang:en-US /highentropyva- /define:"CONFIG=\"Release\",TRACE=-1,_MyType=\"Windows\",PLATFORM=\"AnyCPU\"" /reference:"D:\AppName\Release\AppName 7.4.2\AppName\Main\Source\packages\CrystalDecisions.CrystalReports.10.5\lib\net35\CrystalDecisions.CrystalReports.Engine.dll","D:\AppName\Release\AppName 7.4.2\AppName\Main\Source\packages\CrystalDecisions.CrystalReports.10.5\lib\net35\CrystalDecisions.Enterprise.Framework.dll","D:\AppName\Release\AppName 7.4.2\AppName\Main\Source\packages\CrystalDecisions.CrystalReports.10.5\lib\net35\CrystalDecisions.Enterprise.InfoStore.dll","D:\AppName\Release\AppName 7.4.2\AppName\Main\Source\packages\CrystalDecisions.CrystalReports.10.5\lib\net35\CrystalDecisions.ReportSource.dll","D:\AppName\Release\AppName 7.4.2\AppName\Main\Source\packages\CrystalDecisions.CrystalReports.10.5\lib\net35\CrystalDecisions.Shared.dll","D:\AppName\Release\AppName 7.4.2\AppName\Main\Source\packages\CrystalDecisions.CrystalReports.10.5\lib\net35\CrystalDecisions.Windows.Forms.dll","D:\AppName\Release\AppName 7.4.2\Dependencies\AppName.Base\AppName.ApplicationInfo.dll","D:\AppName\Release\AppName 7.4.2\Dependencies\AppName.Base\AppName.Data.Access.dll","D:\AppName\Release\AppName 7.4.2\Dependencies\AppName.Base\AppName.Data.dll","D:\AppName\Release\AppName 7.4.2\Dependencies\AppName.Base\AppName.Data.SQLServer.dll","D:\AppName\Release\AppName 7.4.2\Dependencies\AppName.Base\AppName.Extensions.dll","D:\AppName\Release\AppName 7.4.2\Dependencies\AppName.Base\AppName.Fehler.dll","D:\AppName\Release\AppName 7.4.2\AppName\Main\Source\Gis\Gis\bin\Release\AppName.Gis.dll","D:\AppName\Release\AppName 7.4.2\AppName\Main\Source\Developer\IDeveloper\bin\Release\AppName.IDeveloper.dll","D:\AppName\Release\AppName 7.4.2\Dependencies\AppName.Base\AppName.Main.dll","D:\AppName\Release\AppName 7.4.2\AppName\Main\Source\Project\Project.Management.Shared\bin\Release\AppName.Project.Management.Shared.dll","D:\AppName\Release\AppName 7.4.2\AppName\Main\Source\Project\Project.Management.Data\bin\Release\AppName.Project.ManagementData.dll","D:\AppName\Release\AppName 7.4.2\Dependencies\AppName.Base\AppName.Resources.dll","D:\AppName\Release\AppName 7.4.2\AppName\Main\Source\packages\iTextSharp.4.1.6.1\lib\net35\iTextSharp.dll","C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll","C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll",C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll,"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.Entity.dll",C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll,C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll,C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll,C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll,"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /debug- /filealign:512 /optimize+ /out:obj\Release\AppName.Developer.Base.dll /ruleset:"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\\Rule Sets\MinimumRecommendedRules.ruleset" /target:library /utf8output ..\..\AppName.AssemblyInfo.vb ApplicationInfoDev.vb Data\Tables\Gcf\Application.vb Data\Tables\Gcf\Control.vb Data\Tables\Gcf\DeveloperMakro.vb Data\Tables\Gcf\DeveloperMenu.vb Data\Tables\Gcf\Dialog.vb Data\Tables\Gcf\Link.vb Data\Tables\Gcf\ListValue.vb Data\Tables\Gcf\MetaRelationen.vb Data\Tables\Gcf\Search.vb Data\Tables\Gcf\SearchColumns.vb Data\Tables\Gcf\Style.vb Data\Tables\Gcf\System.vb Data\Tables\Gcf\TabellenDefinition.vb Data\Tables\Pro\CFG_MetaRelationen.vb Data\Tables\Pro\CFG_MultiEditor.vb Data\Tables\Pro\Gruppen.vb Data\Tables\Pro\Relationen.vb Data\Tables\User\Pfade.vb Data\Tables\User\SyncronisationsVerwaltung.vb Data\UpgradeDeveloperMDB.vb Developer\CFG.vb Developer\CFGInfo.vb Developer\DummyGCF.vb Developer\HistoryBaseBL.vb Developer\HistoryBL.vb Developer\ICFGInfo.vb Developer\IDeveloperApplicationInfo.vb Developer\KarteiBL.InitBL.vb Developer\KarteiBL.vb Developer\MapAndReport.vb Developer\Menu.vb Developer\MenuCreator.vb Developer\MultiEditorBoxBL.vb Developer\MultiEditorGisPickerBL.vb Developer\PlugIn\AlkAlb\AlkAlbPlugIn.vb Developer\PlugIn\Alkis\AlkisPlugin.vb Developer\PlugIn\DummyPlugIn.vb Developer\PlugIn\PlugInFactory.vb Developer\PlugIn\PlugInServices.vb Developer\PrintDataTablePDF.vb Developer\Report.vb Developer\SearchBL.Preselect.vb Developer\SearchBL.vb Developer\SynchronisationsBaseBL.vb Developer\SynchronisationsBL.vb Developer\UpdateFunctionsBL.vb Extensions\DeveloperExtensions.vb Fehler\DeveloperException.vb Fehler\Protocol.vb "My Project\AssemblyInfo.vb" Objektgestaltung\ObjektgestaltungBL.vb /warnaserror+:41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 (TaskId:21)

Eventlog:

Application: vbc.exe
Framework Version: v4.0.30319
Description: The application requested process termination through System.Environment.FailFast(string message).
Message: System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.CodeAnalysis.CodeGen.ILBuilder.ForwardLabelsNoLeaving()
   at Microsoft.CodeAnalysis.CodeGen.ILBuilder.RealizeBlocks()
   at Microsoft.CodeAnalysis.CodeGen.ILBuilder.Realize()
   at Microsoft.CodeAnalysis.VisualBasic.CodeGen.CodeGenerator.GenerateImpl()
   at Microsoft.CodeAnalysis.VisualBasic.MethodCompiler.GenerateMethodBody(PEModuleBuilder moduleBuilder, MethodSymbol method, Int32 methodOrdinal, BoundStatement block, ImmutableArray`1 lambdaDebugInfo, ImmutableArray`1 closureDebugInfo, StateMachineTypeSymbol stateMachineTypeOpt, VariableSlotAllocator variableSlotAllocatorOpt, DebugDocumentProvider debugDocumentProvider, DiagnosticBag diagnostics, Boolean emittingPdb)
   at Microsoft.CodeAnalysis.VisualBasic.MethodCompiler.LowerAndEmitMethod(MethodSymbol method, Int32 methodOrdinal, BoundBlock block, Binder binderOpt, TypeCompilationState compilationState, DiagnosticBag diagsForCurrentMethod, ProcessedFieldOrPropertyInitializers processedInitializers, SynthesizedSubmissionFields previousSubmissionFields, MethodSymbol constructorToInject, Int32& delegateRelaxationIdDispenser)
   at Microsoft.CodeAnalysis.VisualBasic.MethodCompiler.CompileMethod(MethodSymbol method, Int32 methodOrdinal, Int32& withEventPropertyIdDispenser, Int32& delegateRelaxationIdDispenser, Predicate`1 filter, TypeCompilationState compilationState, ProcessedFieldOrPropertyInitializers processedInitializers, Binder containingTypeBinder, SynthesizedSubmissionFields previousSubmissionFields, MethodSymbol& referencedConstructor)
   at Microsoft.CodeAnalysis.VisualBasic.MethodCompiler.CompileNamedType(NamedTypeSymbol containingType, Predicate`1 filter)
   at Microsoft.CodeAnalysis.VisualBasic.MethodCompiler._Closure$__30-0._Lambda$__0()
Stack:
   at System.Environment.FailFast(System.String, System.Exception)
   at Microsoft.CodeAnalysis.FatalError.Report(System.Exception, System.Action`1<System.Exception>)
   at Microsoft.CodeAnalysis.FatalError.ReportUnlessCanceled(System.Exception)
   at Microsoft.CodeAnalysis.VisualBasic.MethodCompiler+_Closure$__30-0._Lambda$__0()
   at Microsoft.CodeAnalysis.CodeGen.ILBuilder.ForwardLabelsNoLeaving()
   at Microsoft.CodeAnalysis.CodeGen.ILBuilder.RealizeBlocks()
   at Microsoft.CodeAnalysis.CodeGen.ILBuilder.Realize()
   at Microsoft.CodeAnalysis.VisualBasic.CodeGen.CodeGenerator.GenerateImpl()
   at Microsoft.CodeAnalysis.VisualBasic.MethodCompiler.GenerateMethodBody(Microsoft.CodeAnalysis.VisualBasic.Emit.PEModuleBuilder, Microsoft.CodeAnalysis.VisualBasic.Symbols.MethodSymbol, Int32, Microsoft.CodeAnalysis.VisualBasic.BoundStatement, System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.CodeGen.LambdaDebugInfo>, System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.CodeGen.ClosureDebugInfo>, Microsoft.CodeAnalysis.VisualBasic.StateMachineTypeSymbol, Microsoft.CodeAnalysis.CodeGen.VariableSlotAllocator, Microsoft.CodeAnalysis.CodeGen.DebugDocumentProvider, Microsoft.CodeAnalysis.DiagnosticBag, Boolean)
   at Microsoft.CodeAnalysis.VisualBasic.MethodCompiler.LowerAndEmitMethod(Microsoft.CodeAnalysis.VisualBasic.Symbols.MethodSymbol, Int32, Microsoft.CodeAnalysis.VisualBasic.BoundBlock, Microsoft.CodeAnalysis.VisualBasic.Binder, Microsoft.CodeAnalysis.VisualBasic.TypeCompilationState, Microsoft.CodeAnalysis.DiagnosticBag, ProcessedFieldOrPropertyInitializers, Microsoft.CodeAnalysis.VisualBasic.SynthesizedSubmissionFields, Microsoft.CodeAnalysis.VisualBasic.Symbols.MethodSymbol, Int32 ByRef)
   at Microsoft.CodeAnalysis.VisualBasic.MethodCompiler.CompileMethod(Microsoft.CodeAnalysis.VisualBasic.Symbols.MethodSymbol, Int32, Int32 ByRef, Int32 ByRef, System.Predicate`1<Microsoft.CodeAnalysis.VisualBasic.Symbol>, Microsoft.CodeAnalysis.VisualBasic.TypeCompilationState, ProcessedFieldOrPropertyInitializers, Microsoft.CodeAnalysis.VisualBasic.Binder, Microsoft.CodeAnalysis.VisualBasic.SynthesizedSubmissionFields, Microsoft.CodeAnalysis.VisualBasic.Symbols.MethodSymbol ByRef)
   at Microsoft.CodeAnalysis.VisualBasic.MethodCompiler.CompileNamedType(Microsoft.CodeAnalysis.VisualBasic.Symbols.NamedTypeSymbol, System.Predicate`1<Microsoft.CodeAnalysis.VisualBasic.Symbol>)
   at Microsoft.CodeAnalysis.VisualBasic.MethodCompiler+_Closure$__30-0._Lambda$__0()
   at Roslyn.Utilities.UICultureUtilities+<>c__DisplayClass5_0.<WithCurrentUICulture>b__0()
   at System.Threading.Tasks.Task.Execute()
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef)
   at System.Threading.Tasks.Task.ExecuteEntry(Boolean)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()

Name der fehlerhaften Anwendung: vbc.exe, Version: 1.1.0.51109, Zeitstempel: 0x56413998
Name des fehlerhaften Moduls: unknown, Version: 0.0.0.0, Zeitstempel: 0x00000000
Ausnahmecode: 0x80131623
Fehleroffset: 0x00007ffa4aea0ebb
ID des fehlerhaften Prozesses: 0x386c
Startzeit der fehlerhaften Anwendung: 0x01d12c22651d48c0
Pfad der fehlerhaften Anwendung: C:\Program Files (x86)\MSBuild\14.0\bin\vbc.exe
Pfad des fehlerhaften Moduls: unknown
Berichtskennung: 4e46e2e1-942f-472e-94e5-b4095cb6aaa5
Vollständiger Name des fehlerhaften Pakets: 
Anwendungs-ID, die relativ zum fehlerhaften Paket ist: 
AdamSpeight2008 commented 8 years ago

Side Question: Is your culture German?

christopherstamm commented 8 years ago

Yes, Culture is German, Visual Studio is in english Os Windows 10 Pro 1511 German

jaredpar commented 8 years ago

Thanks for reporting this issue. We are taking a look at it.

AlekseyTs commented 8 years ago

@ChristopherStamm It would be helpful if you could share the VB code that is causing the compiler to crash.

ish-michael commented 8 years ago

Hello,

Had the same issue after Update 1. Could figure out the reason -> Invalid Imports statement (Imports xxxxxx), which was not found anymore. Perhabs this could help you.

christopherstamm commented 8 years ago

Hello,

I have found the Function with the responsible code.

To complier crashes on "Exit Try" with an empty "Finally" block. Inserting some dummy code into the "Finally" block fixes the compiler crash I can reproduce this behavior in other Functions by removing the code from the "Finally" block

(This is very old code and needs refactoring :-) )

Private Sub GetMainDialog()
    Const tmp1 = "tmpPrepareMainSelection1"
    Const tmp2 = "tmpPrepareMainSelection2"
    Try
        Dim mainTable = "-"
        For Each cfgDlgInfo In Gcf.GetDialogInfos()
            If cfgDlgInfo.HauptDialog AndAlso cfgDlgInfo.ID <> DlgInfo.ID Then
                mainTable = cfgDlgInfo.Tabelle
                If Gcf.LinkBL.LinkExists(DlgInfo.Tabelle, cfgDlgInfo.Tabelle) Then
                    Dim linkInfos = Gcf.LinkBL.GetLinkInfos(DlgInfo.Tabelle, cfgDlgInfo.Tabelle)
                    If linkInfos.IsNotNull() Then
                        MainGIS.GisData.CreateTempTable(tmp1, tmp2, linkInfos)
                        SelectionNameManager.Add(tmp2, "")
                        If DataGIS.Table(tmp2).Rows.Count > 0 Then
                            DataGIS.CreateSelectionFromTable(tmp2, cfgDlgInfo.Tabelle)
                            DlgInfo = cfgDlgInfo
                            Exit Try
                        End If
                    End If
                End If
            End If
        Next
        Throw New Fehler.InfoException(String.Format(Resources.WRN_0010, mainTable))    
    Finally
    End Try
End Sub
adraut commented 8 years ago

I was able to work around this by disabling optimizations.

AlekseyTs commented 8 years ago

I can repro the crash with the following code compiled with /optimize+:

Private Sub Test()
    Try
        Dim mainTable = "-"
        For Each x In {""}
            If String.IsNullOrEmpty(x) Then
                Exit Try
            End If
        Next
        Throw New System.NotSupportedException()    
    Finally
    End Try
End Sub
AlekseyTs commented 8 years ago

@gafter Please verify.