Search Unity

Incremental Compiler dies because of OutOfMemoryException and never restarts

Discussion in '2018.2 Beta' started by SugoiDev, Jun 22, 2018.

  1. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    222
    I'm doing a stress test on the Incremental Compiler and have logs for a situation that occurs where the compiler dies and never restarts. The editor is left in a "compiling..." state forever.
    Currently on the 0.0.42-preview.9 incremental compiler, with unity 2018.2.0b9
    This machine has 32GB of ram, so something could be off for it to be filling that much memory.

    Here's the relevant log:

    Code (csharp):
    1.  (0,0): Emitting to : V:\LOSTALLOY\Aftertile\Unity3D\Temp\Aftertile.dll
    2. (0,0): Aftertile.dll 5594ms  re-parsed: source(0) metadata(1)
    3. (0,0): Emit exception: System.OutOfMemoryException: Out of memory
    4.   at (wrapper alloc) System.Object.AllocVector(intptr,intptr)
    5.   at System.Collections.Concurrent.ConcurrentQueue`1+Segment[T]..ctor (System.Int32 boundedLength) [0x00006] in <f826c2584fc94ec19a48a6576640bdc5>:0
    6.   at System.Collections.Concurrent.ConcurrentQueue`1[T].EnqueueSlow (T item) [0x00051] in <f826c2584fc94ec19a48a6576640bdc5>:0
    7.   at System.Collections.Concurrent.ConcurrentQueue`1[T].Enqueue (T item) [0x00010] in <f826c2584fc94ec19a48a6576640bdc5>:0
    8.   at Microsoft.CodeAnalysis.DiagnosticBag.AddRange (System.Collections.Generic.IEnumerable`1[T] diagnostics) [0x00016] in <1b8ca9dcb2d5446eae867ad3dff1473a>:0
    9.   at Microsoft.CodeAnalysis.DiagnosticBag.AddRange (Microsoft.CodeAnalysis.DiagnosticBag bag) [0x0000f] in <1b8ca9dcb2d5446eae867ad3dff1473a>:0
    10.   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileMethod (Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol methodSymbol, System.Int32 methodOrdinal, Microsoft.CodeAnalysis.CSharp.Binder+ProcessedFieldInitializers& processedInitializers, Microsoft.CodeAnalysis.CSharp.SynthesizedSubmissionFields previousSubmissionFields, Microsoft.CodeAnalysis.CSharp.TypeCompilationState compilationState) [0x0057f] in <4652ba6d846541768056d07eed13bbc0>:0
    11.   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamedType (Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol containingType) [0x001d7] in <4652ba6d846541768056d07eed13bbc0>:0
    12.   at Microsoft.CodeAnalysis.CSharp.MethodCompiler+<>c__DisplayClass21_0.<CompileNamedTypeAsTask>b__0 () [0x00000] in <4652ba6d846541768056d07eed13bbc0>:0
    13.   at Roslyn.Utilities.UICultureUtilities+<>c__DisplayClass5_0.<WithCurrentUICulture>b__0 () [0x00038] in <1b8ca9dcb2d5446eae867ad3dff1473a>:0
    14.   at System.Threading.Tasks.Task.InnerInvoke () [0x0000f] in <f826c2584fc94ec19a48a6576640bdc5>:0
    15.   at System.Threading.Tasks.Task.Execute () [0x00010] in <f826c2584fc94ec19a48a6576640bdc5>:0
    16. --- End of stack trace from previous location where exception was thrown ---
    17.   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f826c2584fc94ec19a48a6576640bdc5>:0
    18.   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f826c2584fc94ec19a48a6576640bdc5>:0
    19.   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f826c2584fc94ec19a48a6576640bdc5>:0
    20.   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f826c2584fc94ec19a48a6576640bdc5>:0
    21.   at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <f826c2584fc94ec19a48a6576640bdc5>:0
    22.   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.WaitForWorkers () [0x00012] in <4652ba6d846541768056d07eed13bbc0>:0
    23.   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileMethodBodies (Microsoft.CodeAnalysis.CSharp.CSharpCompilation compilation, Microsoft.CodeAnalysis.CSharp.Emit.PEModuleBuilder moduleBeingBuiltOpt, System.Boolean emittingPdb, System.Boolean emitTestCoverageData, System.Boolean hasDeclarationErrors, Microsoft.CodeAnalysis.DiagnosticBag diagnostics, System.Predicate`1[T] filterOpt, System.Threading.CancellationToken cancellationToken) [0x00050] in <4652ba6d846541768056d07eed13bbc0>:0
    24.   at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CompileMethods (Microsoft.CodeAnalysis.Emit.CommonPEModuleBuilder moduleBuilder, System.Boolean emittingPdb, System.Boolean emitMetadataOnly, System.Boolean emitTestCoverageData, Microsoft.CodeAnalysis.DiagnosticBag diagnostics, System.Predicate`1[T] filterOpt, System.Threading.CancellationToken cancellationToken) [0x000aa] in <4652ba6d846541768056d07eed13bbc0>:0
    25.   at Microsoft.CodeAnalysis.Compilation.Emit (System.IO.Stream peStream, System.IO.Stream metadataPEStream, System.IO.Stream pdbStream, System.IO.Stream xmlDocumentationStream, System.IO.Stream win32Resources, System.Collections.Generic.IEnumerable`1[T] manifestResources, Microsoft.CodeAnalysis.Emit.EmitOptions options, Microsoft.CodeAnalysis.IMethodSymbol debugEntryPoint, System.IO.Stream sourceLinkStream, System.Collections.Generic.IEnumerable`1[T] embeddedTexts, Microsoft.CodeAnalysis.CodeGen.CompilationTestData testData, System.Threading.CancellationToken cancellationToken) [0x0005b] in <1b8ca9dcb2d5446eae867ad3dff1473a>:0
    26.   at Microsoft.CodeAnalysis.Compilation.Emit (System.IO.Stream peStream, System.IO.Stream pdbStream, System.IO.Stream xmlDocumentationStream, System.IO.Stream win32Resources, System.Collections.Generic.IEnumerable`1[T] manifestResources, Microsoft.CodeAnalysis.Emit.EmitOptions options, Microsoft.CodeAnalysis.IMethodSymbol debugEntryPoint, System.IO.Stream sourceLinkStream, System.Collections.Generic.IEnumerable`1[T] embeddedTexts, System.IO.Stream metadataPEStream, System.Threading.CancellationToken cancellationToken) [0x001bc] in <1b8ca9dcb2d5446eae867ad3dff1473a>:0
    27.   at UnityEditor.Compilation.IncrementalCompiler.Compilation.EmitAssembly () [0x00091] in <a8c63b0d2bd44913beb37dbb8ccdffcb>:0
    28. (0,0): detected 0 file(s) that have changed
    29. (0,0): Emitting to : V:\LOSTALLOY\Aftertile\Unity3D\Temp\Vendor-Editor.dll
    30. (0,0): Internal compiler error: System.NullReferenceException: Object reference not set to an instance of an object
    31.   at UnityEditor.Compilation.IncrementalCompiler.Compilation.EmitAssembly () [0x000f8] in <a8c63b0d2bd44913beb37dbb8ccdffcb>:0
    32. - Finished compile Library/ScriptAssemblies/Aftertile.dll
    33. - Starting compile Library/ScriptAssemblies/Devel.dll
    34. (0,0): Devel.dll compiling...
    35. (0,0): MetadataShareCache threw an exception: System.OutOfMemoryException: Out of memory
    36.   at (wrapper managed-to-native) System.Runtime.InteropServices.Marshal.AllocHGlobal(intptr)
    37.   at System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Int32 cb) [0x00006] in <f826c2584fc94ec19a48a6576640bdc5>:0
    38.   at System.Reflection.Internal.NativeHeapMemoryBlock..ctor (System.Int32 size) [0x00006] in <6e996dbb3f9b4d42bb708be9f37ced22>:0
    39.   at System.Reflection.Internal.StreamMemoryBlockProvider.ReadMemoryBlockNoLock (System.IO.Stream stream, System.Boolean isFileStream, System.Int64 start, System.Int32 size) [0x00000] in <6e996dbb3f9b4d42bb708be9f37ced22>:0
    40.   at System.Reflection.PortableExecutable.PEReader..ctor (System.IO.Stream peStream, System.Reflection.PortableExecutable.PEStreamOptions options, System.Int32 size) [0x00093] in <6e996dbb3f9b4d42bb708be9f37ced22>:0
    41.   at System.Reflection.PortableExecutable.PEReader..ctor (System.IO.Stream peStream, System.Reflection.PortableExecutable.PEStreamOptions options) [0x00000] in <6e996dbb3f9b4d42bb708be9f37ced22>:0
    42.   at Microsoft.CodeAnalysis.ModuleMetadata.CreateFromStream (System.IO.Stream peStream, System.Reflection.PortableExecutable.PEStreamOptions options) [0x00047] in <1b8ca9dcb2d5446eae867ad3dff1473a>:0
    43.   at Microsoft.CodeAnalysis.MetadataReference.CreateFromFile (System.String path, Microsoft.CodeAnalysis.MetadataReferenceProperties properties, Microsoft.CodeAnalysis.DocumentationProvider documentation) [0x00006] in <1b8ca9dcb2d5446eae867ad3dff1473a>:0
    44.   at UnityEditor.Compilation.IncrementalCompiler.MetaDataSharedCache.CreateCacheEntry (System.String assemblyPath, UnityEditor.Compilation.IncrementalCompiler.CompilationReport compilationReport) [0x0000e] in <a8c63b0d2bd44913beb37dbb8ccdffcb>:0
    45. (0,0): Emitting to : V:\LOSTALLOY\Aftertile\Unity3D\Temp\Devel.dll
    46. (0,0): Devel.dll 71ms  re-parsed: source(0) metadata(1)
    47. (0,0): detected 0 file(s) that have changed
    48. - Finished compile Library/ScriptAssemblies/Devel.dll
     
  2. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,219
    Do you have a bug report # ?
     
  3. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    222
    Sorry, I was stress testing for different issue so the log was lost.

    I'll reproduce again and post the # back here.
     
  4. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    222
    Oh, well. I just got it again pretty fast. Waiting for the email to get the #
    I didn't attach the project because it's large, but any large-ish project will probably trigger the bug fast with the stress tester script I included.
     
  5. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    222
    #1052147
     
    LeonhardP likes this.