Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Bug Stack Overflow Error causing build to fail? (2020.2.0b8 and 2020.2.0b9)

Discussion in '2020.2 Beta' started by NotaNaN, Oct 29, 2020.

  1. NotaNaN

    NotaNaN

    Joined:
    Dec 14, 2018
    Posts:
    325
    All of my code works fantastic in the editor — but when I try to build my game, I receive a Stack Overflow error, causing the build to fail. This error occurred in 2020.2.0b8, but I hoped upgrading to 2020.2.0b9 was going to magically remedy it. (It did not). :(

    Anybody here speak Stacktrace? :oops:

    Code (CSharp):
    1. Stack overflow.
    2. 0x00007ff6b8bb698c (Unity) StackWalker::GetCurrentCallstack
    3. 0x00007ff6b8bbed69 (Unity) StackWalker::ShowCallstack
    4. 0x00007ff6ba07541c (Unity) GetStacktrace
    5. 0x00007ff6bb114d33 (Unity) DebugStringToFile
    6. 0x00007ff6b8c6e789 (Unity) DebugLogHandler_CUSTOM_Internal_Log
    7. 0x000001750e7bebfb (Mono JIT Code) (wrapper managed-to-native) UnityEngine.DebugLogHandler:Internal_Log (UnityEngine.LogType,UnityEngine.LogOption,string,UnityEngine.Object)
    8. 0x000001750e7beb2b (Mono JIT Code) UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
    9. 0x000001750e7be870 (Mono JIT Code) UnityEngine.Logger:Log (UnityEngine.LogType,object)
    10. 0x000001778c911605 (Mono JIT Code) UnityEngine.Debug:LogError (object)
    11. 0x000001778c9109d3 (Mono JIT Code) UnityEditor.Build.Player.BuildPlayerDataGeneratorProcess:ProcessExit (UnityEditor.Utils.Program)
    12. 0x000001778c9108cb (Mono JIT Code) UnityEditor.Build.Player.BuildPlayerDataGeneratorProcess/<>c__DisplayClass4_0:<Execute>b__0 (object,System.EventArgs)
    13. 0x000001778c910657 (Mono JIT Code) System.Diagnostics.Process:OnExited ()
    14. 0x000001778c91048b (Mono JIT Code) System.Diagnostics.Process:RaiseOnExited ()
    15. 0x000001750671cb6b (Mono JIT Code) System.Diagnostics.Process:WaitForExit (int)
    16. 0x000001778c90da4b (Mono JIT Code) (wrapper remoting-invoke-with-check) System.Diagnostics.Process:WaitForExit (int)
    17. 0x000001778c90d933 (Mono JIT Code) UnityEditor.Utils.Program:WaitForExit (int)
    18. 0x000001778c907473 (Mono JIT Code) UnityEditor.Build.Player.BuildPlayerDataGeneratorProcess:Execute (UnityEditor.Build.Player.BuildPlayerDataGeneratorOptions)
    19. 0x000001778c903a2e (Mono JIT Code) UnityEditor.Build.Player.BuildPlayerDataGenerator:GenerateForAssemblies (string[],string[],UnityEditor.BuildTarget,bool)
    20. 0x000001778c9033d3 (Mono JIT Code) UnityEditor.Build.Player.BuildPlayerDataGeneratorNativeInterface:GenerateForAssemblies (string[],string[],UnityEditor.BuildTarget,bool)
    21. 0x000001778c9034b3 (Mono JIT Code) (wrapper runtime-invoke) <Module>:runtime_invoke_void_object_object_int_byte (object,intptr,intptr,intptr)
    22. 0x00007ffd34c7de60 (mono-2.0-bdwgc) [mini-runtime.c:2812] mono_jit_runtime_invoke
    23. 0x00007ffd34c02902 (mono-2.0-bdwgc) [object.c:2921] do_runtime_invoke
    24. 0x00007ffd34c0b95f (mono-2.0-bdwgc) [object.c:2968] mono_runtime_invoke
    25. 0x00007ff6b8a345d4 (Unity) scripting_method_invoke
    26. 0x00007ff6b8a2cde5 (Unity) ScriptingInvocation::Invoke
    27. 0x00007ff6b8a25f55 (Unity) ScriptingInvocation::Invoke<void>
    28. 0x00007ff6b70ac935 (Unity) Scripting::UnityEditor::Build::Player::BuildPlayerDataGeneratorNativeInterfaceProxy::GenerateForAssemblies
    29. 0x00007ff6ba379cc0 (Unity) BuildPipeline::GenerateBuildPlayerData
    30. 0x00007ff6ba377b45 (Unity) BuildPipeline::GenerateAssemblyTypeInfos
    31. 0x00007ff6bb455bd3 (Unity) ProducePlayerScriptAssemblies
    32. 0x00007ff6bb444670 (Unity) BuildPlayer
    33. 0x00007ff6ba921cbf (Unity) BuildPipeline::BuildPlayerInternalNoCheck
    34. 0x00007ff6ba74400a (Unity) BuildPipeline_CUSTOM_BuildPlayerInternalNoCheck
    35. 0x00000176ff9fcbca (Mono JIT Code) (wrapper managed-to-native) UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck (string[],string,string,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,UnityEditor.BuildOptions,string[],bool)
    36. 0x00000176ff9fc513 (Mono JIT Code) UnityEditor.BuildPlayerWindow/DefaultBuildMethods:BuildPlayer (UnityEditor.BuildPlayerOptions)
    37. 0x00000176ff9f85db (Mono JIT Code) UnityEditor.BuildPlayerWindow:CallBuildMethods (bool,UnityEditor.BuildOptions)
    38. 0x00000176d3a06323 (Mono JIT Code) UnityEditor.BuildPlayerWindow:GUIBuildButtons (UnityEditor.Modules.IBuildWindowExtension,bool,bool,bool,UnityEditor.Build.BuildPlatform)
    39. 0x00000176d39fb933 (Mono JIT Code) UnityEditor.BuildPlayerWindow:ShowBuildTargetSettings ()
    40. 0x00000176d39eaa43 (Mono JIT Code) UnityEditor.BuildPlayerWindow:OnGUI ()
    41. 0x00000176d39a7e83 (Mono JIT Code) UnityEditor.HostView:InvokeOnGUI (UnityEngine.Rect,UnityEngine.Rect)
    42. 0x00000176d39a7c33 (Mono JIT Code) UnityEditor.DockArea:DrawView (UnityEngine.Rect,UnityEngine.Rect)
    43. 0x00000176d399b8d3 (Mono JIT Code) UnityEditor.DockArea:OldOnGUI ()
    44. 0x00000176d3982960 (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:DoOnGUI (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,bool,UnityEngine.Rect,System.Action,bool)
    45. 0x00000176d3981aab (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,System.Action,bool)
    46. 0x00000176ff9e8a7b (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event,System.Action,bool)
    47. 0x00000176ff9e8903 (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event,bool)
    48. 0x00000176ff9e821b (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:SendEventToIMGUIRaw (UnityEngine.UIElements.EventBase,bool,bool)
    49. 0x00000176ff9e5833 (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:SendEventToIMGUI (UnityEngine.UIElements.EventBase,bool,bool)
    50. 0x000001750f66b60b (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:HandleEvent (UnityEngine.UIElements.EventBase)
    51. 0x000001750f650718 (Mono JIT Code) UnityEngine.UIElements.CallbackEventHandler:HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase)
    52. 0x00000176ff9e2d23 (Mono JIT Code) UnityEngine.UIElements.MouseCaptureDispatchingStrategy:DispatchEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel)
    53. 0x000001750f64e92e (Mono JIT Code) UnityEngine.UIElements.EventDispatcher:ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel,bool)
    54. 0x000001750f64e423 (Mono JIT Code) UnityEngine.UIElements.EventDispatcher:ProcessEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel)
    55. 0x000001750f653dab (Mono JIT Code) UnityEngine.UIElements.EventDispatcher:ProcessEventQueue ()
    56. 0x000001750f652433 (Mono JIT Code) UnityEngine.UIElements.EventDispatcher:OpenGate ()
    57. 0x000001750f65237b (Mono JIT Code) UnityEngine.UIElements.EventDispatcherGate:Dispose ()
    58. 0x000001750f64e6b3 (Mono JIT Code) UnityEngine.UIElements.EventDispatcher:ProcessEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel)
    59. 0x000001750f64ddf3 (Mono JIT Code) UnityEngine.UIElements.EventDispatcher:Dispatch (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel,UnityEngine.UIElements.DispatchMode)
    60. 0x000001750f64dc6b (Mono JIT Code) UnityEngine.UIElements.BaseVisualElementPanel:SendEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.DispatchMode)
    61. 0x00000176d3945f6b (Mono JIT Code) UnityEngine.UIElements.UIElementsUtility:DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel)
    62. 0x00000176d3945a4b (Mono JIT Code) UnityEngine.UIElements.UIElementsUtility:UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (int,intptr,bool&)
    63. 0x00000176d394584f (Mono JIT Code) UnityEngine.UIElements.UIEventRegistration:ProcessEvent (int,intptr)
    64. 0x00000176d394578b (Mono JIT Code) UnityEngine.UIElements.UIEventRegistration/<>c:<.cctor>b__1_2 (int,intptr)
    65. 0x00000176d39455ed (Mono JIT Code) UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    66. 0x00000176d394569e (Mono JIT Code) (wrapper runtime-invoke) <Module>:runtime_invoke_void_int_intptr_intptr& (object,intptr,intptr,intptr)
    67. 0x00007ffd34c7de60 (mono-2.0-bdwgc) [mini-runtime.c:2812] mono_jit_runtime_invoke
    68. 0x00007ffd34c02902 (mono-2.0-bdwgc) [object.c:2921] do_runtime_invoke
    69. 0x00007ffd34c0b95f (mono-2.0-bdwgc) [object.c:2968] mono_runtime_invoke
    70. 0x00007ff6b8a345d4 (Unity) scripting_method_invoke
    71. 0x00007ff6b8a2cde5 (Unity) ScriptingInvocation::Invoke
    72. 0x00007ff6b8a25f55 (Unity) ScriptingInvocation::Invoke<void>
    73. 0x00007ff6b70fdaed (Unity) Scripting::UnityEngine::GUIUtilityProxy::ProcessEvent
    74. 0x00007ff6b964f086 (Unity) GUIView::ProcessRetainedMode
    75. 0x00007ff6ba0b7485 (Unity) GUIView::OnInputEvent
    76. 0x00007ff6b964ef78 (Unity) GUIView::ProcessInputEvent
    77. 0x00007ff6ba0b894b (Unity) GUIView::ProcessEventMessages
    78. 0x00007ff6ba0aff13 (Unity) GUIView::GUIViewWndProc
    79. 0x00007ffd8e855c1d (USER32) CallWindowProcW
    80. 0x00007ffd8e855612 (USER32) DispatchMessageW
    81. 0x00007ff6ba07ea49 (Unity) MainMessageLoop
    82. 0x00007ff6ba082af1 (Unity) WinMain
    83. 0x00007ff6bbea71f6 (Unity) __scrt_common_main_seh
    84. 0x00007ffd8d8e7c24 (KERNEL32) BaseThreadInitThunk
    85. 0x00007ffd8ed2cea1 (ntdll) RtlUserThreadStart
    86.  

    EDIT:
    Just as a quick note:
    My builds do not really "fail" in the sense that the build was unable to complete.
    The builds do complete — it's just an error is thrown part way (Stack Overflow error) and when I run my build-ed application stuff is really broken.
     
    Last edited: Oct 29, 2020
    MilenaRocha likes this.
  2. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,371
    That just looks like the stack trace for Debug.Log. In particular, it looks like the stack trace of somebody pressing the "build" button, and the build process writing something to the console.

    Not 100% sure, but it might be that the actual stack overflow is somewhere else? The vast majority of stack overflows are infinite loops involving recursive methods, but they can also happen if you try to obscenely much stuff on the stack for other reasons.
     
    NotaNaN likes this.
  3. NotaNaN

    NotaNaN

    Joined:
    Dec 14, 2018
    Posts:
    325
    Thanks for the reply! :D

    Yeah, I was worried you might say something along the lines of that. :oops:

    Every week, I make a build of my project to make sure everything is going smoothly and still runs properly in-build. The issue is that I have made hundreds of edits and added many more files since my last successful build. Trying to debug an error that occurs only on build compilation, of which can only be tested by removing files from a project (and those files are tangled with dependencies, mind you), sounds like the ultimate debugging nightmare. :(

    In my project, I do not have a single recursive method (that I am aware of), and even if I did, shouldn't it blow up when the method runs, rather than when the code gets compiled — or more oddly, compiled for a build?
    I'm not the brightest bulb in the box, which is why I'm asking if this would be the normal behavior (as this is what I always expected).

    Also, is there any weird, unmentioned upper limit on how many Component you're allowed to have on a single GameObject? Currently, I have 31 Components on one GameObject (2 Unity Components and 29 Scripts, I didn't count the Transform). I'm guessing that isn't the issue... but I felt like I should ask, as I plan to probably double that number before this is over, and it could become in issue. :oops:

    Mr. Baste, sir, I do not suppose you have any arcane intuition of what might cause an issue as this (other than a nasty unbridled recursive method), but if you do, what level of "putting an obscene amount of stuff on the stack" is required in order to cause the build to fail on compile? (I'd love to know, because after you answer I'm probably going to backup my project and slowly tear out files until I find the problematic one). :(


    Any and all replies are greatly appreciated!
    Thank you for the time you have already spent assisting me troubleshoot. :)
     
    MilenaRocha likes this.
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,756
    I suggest attaching Visual Studio to Unity.exe before initiating the build. Hopefully that makes it catch the crash and give you the real callstack.
     
    NotaNaN likes this.
  5. NotaNaN

    NotaNaN

    Joined:
    Dec 14, 2018
    Posts:
    325
    I will try this as soon as I'm able and I will update the thread with the real stack! Hopefully it's ridiculously obvious where my problem is once I get it. :)

    Thanks for the recommendation! :D
     
    Last edited: Oct 29, 2020
  6. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,371
    Well, since you're on a beta version of the engine, it might be that you're triggering an internal bug in the engine - aka. "not your fault".

    It's most probably not any of your game code causing this - and, no, there's no limit on the number of MonoBehaviours. If it's crashing during the build, it's due to code that's running during the build - which is either Unity's stuff like the compilation or scene building, or code you've written that happens during build (ie. if you're using OnPostProcessBuild, [PostProcessScene], stuff like that).


    For sure try to attach the debugger to the process.

    If that doesn't tell you anything, a good way to bisect this before you start ripping out files is to check build options. Try just building an empty scene, try building with/without IL2CPP, etc.

    Finally, this is why you use source control. If you'd been using git or svn, you could go back to earlier commits and run builds with them in a binary-search fashion, which would allow you to pretty quickly pinpoint which commit was the problem, rather than having to consider all of your changes as a whole.
     
    NotaNaN likes this.
  7. NotaNaN

    NotaNaN

    Joined:
    Dec 14, 2018
    Posts:
    325
    I attached Visual Studio to the Unity.exe and attempted to build, the build succeeded, but the Stack Overflow error popped up again.

    I noticed that Unity creates two more executables whenever I try to build, so I also connected Visual Studio to "netcorerun.exe" to see if that would give me results. (It did not).

    To attach to Unity, I did (while in Visual Studio):
    Debug > Attach to Process...
    And then navigated to Unity's .exe and attached to it. (Same process for "netcorerun.exe")

    I also tried:
    Debug > Attach Unity Debugger
    However the results were the same.


    Just as a quick note:
    My builds do not really "fail" in the sense that the build was unable to complete.
    The builds do complete — it's just an error is thrown part way (Stack Overflow error) and when I run my build-ed application stuff is really broken.

    I feel like I should have mention that sooner. :oops:
     
    Last edited: Oct 29, 2020
  8. NotaNaN

    NotaNaN

    Joined:
    Dec 14, 2018
    Posts:
    325
    Something tells me it is "my fault" because if I remove all of my scripts from my project the build succeeds without error.
    I know. It's a bad sign.

    Yeah, I figured as much.
    Best-case scenario; I move to an older, more stable Unity version and everything just works. :oops:

    Yeah, I suspected that to be the case. I just wanted to make sure. :p
    I know there are performance hits to GetComponent when it is performed on larger GameObjects due to it getting Components by iterating over all the Components on a GameObject to find the one it wants, though. So there's still a small price to pay. ;)

    Luckily, I don't use OnPostProcessBuild or [PostProcessScene], but I do have some Preprocessor Directives in my code. I've looked over them and it seems like nothing should be causing an issue — none of them really do anything but remove in-editor warnings for myself so that way they do not run in a build. But I'll probably look over them again just to make sure I didn't miss something.

    Smart idea!
    Unfortunately, building an empty scene didn't do anything different — I still have the same errors.
    I was really hoping that was going to work. :(
    I'm about to try IL2CCP.

    Yeah...
    I was using Unity Collaborate for a while as a simple backup system, but then it just broke one day and I was like: "Well, I didn't really need that... I'll move to a proper version control later! What could go wrong?"

    The moral of this story is: that mindset will make you regret every second of your life.


    As an aside,
    Have you tried Plastic SCM? There seems to be some caveats to using it, but it may be worth checking out.
    Either way — I need to Git Gud, or Git Hub.
     
    Last edited: Oct 29, 2020
  9. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,371
    I haven't. We've looked into it, but the advantages it offers over git (which we use) didn't seem to be large enough to make it worthwhile for us to reeducate the entire team to use a new version control software.

    The cool thing with git is that for a personal project, you don't need to have a server you're pushing stuff to, which reduces cost and removes having to deal with accounts and passwords and all that. You just make commits locally. It essentially becomes regular backups where you write what you did before each backup.
     
    NotaNaN likes this.
  10. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,756
    Can you tell me where you see the stack overflow error? If Visual Studio didn't catch it, does that mean Unity doesn't actually crash?
     
    NotaNaN likes this.
  11. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    332
    Can you report a fogbug with your project scripts attached. This seems to be an issue in the script meta data generator that is new in 2020.2.
     
    NotaNaN likes this.
  12. NotaNaN

    NotaNaN

    Joined:
    Dec 14, 2018
    Posts:
    325
    I'm so popular today!

    Thanks for telling me about your experiences with Git, @Baste. I'll probably use that one and make moving to it my "Over-the-Weekend" project for this Saturday. :D

    The Stack Overflow error is in the Unity console.
    And yes, Unity doesn't crash. ;)
    To be super specific — if I were to open Build Settings and then press Build, Unity would start building away, throw the Stack Overflow error partway through, and then finish the build, successfully.

    If you were to run the build (the generated .exe file), however, Null Reference Exceptions would be thrown. This thread over here was a byproduct of that, and as I boiled the issue down, I made this one and resolved the other.

    Hi, and welcome to my thread. :D
    Quick question — what is a fogbug? o_O
    I'm also assuming you want the whole project so that way you can build and see the error for yourself, right? Or do you really just want the scripts? :rolleyes:
    ...
    I'm just gonna give you the scripts. :oops:
     
  13. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    332
    Sorry, fogbug is the internal bug tracker name. Just report a bug via unity and it will end up in there. So if that is what I think it is based on the logs, I just need the scripts/assemblies in your project. No assets as BuildPlayerDataGenerator is just working with the compiled assemblies from your scripts. So I should be able to repro the issue in that log with just the scripts/assemblies.

    The gist is that the BuildPlayerDataGenerator process is generating meta data about the compiled / project assemblies that asset with the content build pipeline. If this generates data incorrectly, or in your case crashes, then that would certainly cause the player to be built incorrectly as a result. Before Unity 2020.2, the code of this process was fully inside of the Unity Editor code base and process. We moved it externally to allow us to run it on demand, and cache results on a per assembly basis which will unlock us being able to create a much better incremental player build experience in the future. Still a lot more work to do on that last front.
     
    NotaNaN likes this.
  14. NotaNaN

    NotaNaN

    Joined:
    Dec 14, 2018
    Posts:
    325
    Right-o!
    A report has been made, so you should receive it shortly! ;)
    Thanks for taking a look! :D

    EDIT 1:
    Oops, here's the case number: 1288883

    Sorry, I forgot that part.
    I got excited. :p
     
    Last edited: Oct 29, 2020
    LeonhardP likes this.