Opened 5 years ago

Closed 3 years ago

#5578 closed defect (fixed)

Segfault if PushGUIPage + JS error in GUI page init function

Reported by: elexis Owned by:
Priority: Should Have Milestone: Alpha 25
Component: Core engine Keywords:
Cc: Patch:

Description

When a GUI page is opened, the init function is called.

If that init function is calling Engine.PushGUIPage, and if then in the same function a JS exception is thrown, the entire thing crashes.

This bug is reproducible in both alpha 23 and current svn (r22812), so it is not related to SM45 or the source/gui/ rewrite.

Example:

Index: binaries/data/mods/public/gui/pregame/mainmenu.js
===================================================================
--- binaries/data/mods/public/gui/pregame/mainmenu.js	(revision 22810)
+++ binaries/data/mods/public/gui/pregame/mainmenu.js	(working copy)
@@ -48,6 +48,9 @@
 	Engine.GetGUIObjectByName("lobbyButton").tooltip = colorizeHotkey(
 		translate("%(hotkey)s: Launch the multiplayer lobby to join and host publicly visible games and chat with other players."),
 		"lobby");
+
+	ShowSplashScreen();
+	throw new Error("meh");
 }
 
 function getHotloadData()

Perhaps it's the reason why the splash screen is opened in onTick rather than init in the original code.

Change History (3)

comment:1 by elexis, 5 years ago

One can also trigger a crash when hotloading and opening a page:

It will then crash inside boost:

(boost::unordered_set<VfsPath> inputs; for hotloading)

from CGUIManager::ReloadAllPages().

This exact crash was apparently "fixed" / untriggered in r13597 where it was moved from init to onTick.

comment:2 by elexis, 5 years ago

So if it turns out to be impossible by design to reliably not crash when calling PushGUIPage from init, perhaps it could be made impossible to call that page from init, by only registering this function later. Fixing would be better, but copying the SGUIPage (like is done for other page iteration) doesnt seem to work either.

Duplicate of #2042.

comment:3 by wraitii, 3 years ago

Milestone: BacklogAlpha 25
Priority: Must HaveShould Have
Resolution: fixed
Status: newclosed

Fixed in Phab:rP25616

Note: See TracTickets for help on using tickets.