• Switch 1.4: New patch released Jan 18, details are here. Read the full release details here. Report bugs here.

Resolved Startup silent crash caused by a stack overflow due to recursion.

Phibonacci

Terrarian
Steam or GOG
Steam
Single Player/Multiplayer
Both
Operating System
Windows 8/8.1
Terraria Version
1.4.2.3
Controls Used
Keyboard/Mouse
This crash only happens to some people, for unknown reasons. It only happen when the user focuses another window while Terraria launches (seems expectable due to the check to drawToScreen), and outputs no stack trace, because uh well, overflow lol. What exactly happen is:
Terraria.Main.InitTargets() calls Terraria.Main.UpdateDisplaySettings(), which calls Terraria.Main.SetResolution(int, int), which in turn calls Terraria.Main.SetDisplayMode(int, int, bool).
Then, near the end of this last method, if Terraria.Main.drawToScreen is false, it calls back to Terraria.Main.InitTargets(). Recursion ensues, and a stack overflow is thrown soon enough.
I did patch my client (due to how infuriating this crash is), and added a (static) flag to the Terraria.Main.drawToScreen check, so it is like: if (!Main.drawToScreen && !Main.noRecursionFlag) {Main.noRecursionFlag = true; Main.InitTargets();} etc, and it never crashed this way ever again.
Would be nice if it could be patched :0
Oh and it has happened since 1.4.1.x I think, or maybe since 1.4 I have no idea.
 
Last edited:

Phibonacci

Terrarian
Just looked at the code & tested again, and it was fixed! Thanks a lot @Yoraiz0r (assuming you are the one who did since Leinfors said they showed this thread to you).
I'm aware of a few other bugs, and will try to make a proper report for each soon. If this thread could please be marked as resolved.
Thanks again : )
 

Leinfors

Quality Assurance
Staff member
Moderator
Re-Logic
I'm glad you checked back in and confirmed the fix!

I'll update our issue ticket to indicate it is resolved, and let Yorai know your thanks. :)
 
Top Bottom