Opened 5 months ago

Closed 5 months ago

#6513 closed defect (fixed)

Segfault on autostart nonVisual games

Reported by: Langbart Owned by: bb
Priority: Release Blocker Milestone: Alpha 26
Component: Core engine Keywords:
Cc: Patch: Phab:D4527

Description (last modified by Langbart)


  • start a game from the command line with the -autostart-nonvisual flag
binaries/system/pyrogenesis -conf=mod.enabledmods:"public" -autostart="random/mainland" -autostart-nonvisual
  • Segfault
  • bb has already created a patch. It is better to also create a ticket to increase the chances that it will not be forgotten.
23:14 <@Stan> Langbart: you can also create a rb for non visual mode if you like


(lldb) run -conf=mod.enabledmods:"public" -autostart="random/mainland" -autostart-nonvisual
Process 79078 launched: '/Users/paria/0ad/binaries/system/pyrogenesis' (x86_64)
TIMER| InitVfs: 6.383 ms
FILES| Main log written to '/Users/paria/Library/Application Support/0ad/logs/mainlog.html'
FILES| Interesting log written to '/Users/paria/Library/Application Support/0ad/logs/interestinglog.html'
TIMER| CONFIG_Init: 7.804 ms
Assertion failed: "ms_singleton"
Location: Singleton.h:51 (GetSingleton)

Call stack:

(error while dumping stack: Function not supported)
errno = 0 (No error reported here)
OS error = ?

(C)ontinue, (S)uppress, (B)reak, Launch (D)ebugger, or (E)xit?
Redirecting call to abort() to mozalloc_abort

pyrogenesis was compiled with optimization - stepping may behave oddly; variables may not be available.
Process 79078 stopped
* thread #1, name = 'main', queue = '', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x000000010109c1f0 pyrogenesis`::mozalloc_abort(msg=<unavailable>) at mozalloc_abort.cpp:33:3 [opt]
   30  	#ifdef MOZ_WIDGET_ANDROID
   31  	  abortThroughJava(msg);
   32  	#endif
-> 33  	  MOZ_CRASH();
   34  	}
   36  	#ifdef MOZ_WIDGET_ANDROID
Target 0: (pyrogenesis) stopped.
(lldb) bt
* thread #1, name = 'main', queue = '', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x000000010109c1f0 pyrogenesis`::mozalloc_abort(msg=<unavailable>) at mozalloc_abort.cpp:33:3 [opt]
    frame #1: 0x0000000101b93e3d pyrogenesis`::abort() at mozalloc_abort.cpp:82:3 [opt]
    frame #2: 0x00000001004f2a86 pyrogenesis`sys_display_error(text=<unavailable>, flags=6) at unix.cpp:268:4 [opt]
    frame #3: 0x00000001004d5203 pyrogenesis`debug_DisplayError(wchar_t const*, unsigned long, void*, wchar_t const*, wchar_t const*, int, char const*, long volatile*) [inlined] CallDisplayError(text=L"Assertion failed: \"ms_singleton\"\r\nLocation: Singleton.h:51 (GetSingleton)\r\n\r\nCall stack:\r\n\r\n(error while dumping stack: Function not supported)\r\nerrno = 0 (No error reported here)\r\nOS error = ?\r\n", flags=6) at debug.cpp:374:8 [opt]
    frame #4: 0x00000001004d51e6 pyrogenesis`debug_DisplayError(description=L"Assertion failed: \"ms_singleton\"", flags=6, context=0x00007ffeefbfe000, lastFuncToSkip=<no summary available>, pathname=<no summary available>, line=<no summary available>, func=<no value available>, suppress=<no summary available>) at debug.cpp:460 [opt]
    frame #5: 0x00000001004d5a6e pyrogenesis`debug_OnAssertionFailure(expr=<no summary available>, suppress=<no summary available>, file=<no summary available>, line=<no summary available>, func=<no value available>) at debug.cpp:547:9 [opt]
    frame #6: 0x00000001002ce960 pyrogenesis`CFontMetrics::CFontMetrics(CStrIntern) [inlined] Singleton<CRenderer>::GetSingleton() at Singleton.h:51:3 [opt]
    frame #7: 0x00000001002ce930 pyrogenesis`CFontMetrics::CFontMetrics(this=<no summary available>, font=CStrIntern @ scalar) at FontMetrics.cpp:29 [opt]
    frame #8: 0x00000001001d993c pyrogenesis`CConsole::Init(this=<no summary available>) at CConsole.cpp:97:21 [opt]
    frame #9: 0x0000000100214e5f pyrogenesis`InitPs(setup_gui=<no summary available>, gui_page=<no summary available>, srcScriptInterface=<no summary available>, initData=JS::HandleValue @ scalar) at GameSetup.cpp:201:14 [opt]
    frame #10: 0x0000000100213a36 pyrogenesis`Autostart(args=<no summary available>) at GameSetup.cpp:1127:3 [opt]
    frame #11: 0x00000001002151eb pyrogenesis`InitNonVisual(args=<no summary available>) at GameSetup.cpp:721:2 [opt] [artificial]
    frame #12: 0x0000000100004aaa pyrogenesis`RunGameOrAtlas(argc=<no summary available>, argv=<no summary available>) at main.cpp:672:4 [opt]
    frame #13: 0x00000001000035b6 pyrogenesis`main(argc=<no summary available>, argv=<no summary available>) at main.cpp:743:2 [opt]
    frame #14: 0x00007fff68073cc9 libdyld.dylib`start + 1

Change History (4)

comment:1 by Silier, 5 months ago

Owner: set to bb

comment:2 by Langbart, 5 months ago

Description: modified (diff)

adding a lldb with latest GIT version [26831]

comment:3 by Langbart, 5 months ago

elexis (28/Apr/22)

[23:55:39] elexis it cant work
[23:55:52] elexis he calls InitPs(true, L"page_autostart.xml", &scriptInterface, sessionInitData);
[23:55:58] elexis but thats a GUI page
[23:56:09] elexis so the patch isnt trivial
[23:56:19] elexis yeah revert that
[23:56:45] elexis though the fun thing is that revert isnt trivially a fix either because code relating to it might have changed
[23:57:18] elexis why does he change that c++ function and not test nonvisual
[23:58:07] elexis now we have a wraitii bug concatenated with a bb bug
[00:00:42] elexis before rP26584
[00:00:42] elexis         if (CRenderer::IsInitialised())
[00:00:42] elexis             InitPsAutostart(false, attrs);
[00:00:42] elexis         else
[00:00:42] elexis             ENSURE(g_Game->ReallyStartGame() == PSRETURN_OK);
[00:00:50] elexis after:
[00:00:53] elexis InitPs(true, L"page_autostart.xml", &scriptInterface, sessionInitData);
[00:01:09] elexis this is like half the patch missing
[00:01:23] elexis I mean rP26584 is missing half and rP25077 missed the half
[00:03:02] elexis the bugfix would now be adding those two halves in one patch to make it work again
[00:08:32] elexis #6513 might be fixable with 30 lines C++ diff
[00:54:49] elexis damn, gui/maps/ exists too, why
[00:55:45] elexis ah, because multiple gui pages need it but many dont
[00:57:22] elexis wont be 30 lines, maybe 80-100
Last edited 5 months ago by Langbart (previous) (diff)

comment:4 by wraitii, 5 months ago

Resolution: fixed
Status: newclosed

In 26879:

Fix non-visual autostart, as well as client/host autostart.

Follows rP26584.

Piping the autostart through a GUI page is easy but requires using the GUI in non-visual mode, which is problematic since it's not initialized.
The GUI is not needed, only its ability to load scripts, so this diff fixes the problem by adding an 'entrypoint' script in the new autostart folder that gets called with this unique ability, setting things up properly. The mod mod gets a placeholder.

Other changes:

  • Fix some issues with networked autostart:
    • Players were not assigned slots.
    • The host didn't actually wait for other players.
  • Move gamesettings from gui/gamesettings/ to gamesettings/. This moves attributes as well.
  • Move autostart files from gui/autostart/ to autostart/. Note that gui/autostart/ still exists as it's used in the tutorial button from the main menu.
  • Rename the JSI_VFS functions to be explicitly about their function: the ability to write and the potential restricted folders.
  • Don't require autostart when using --autostart-client in non-visual mode.

Starting the autostart client/host has poor UX in some situations, but improving that feature is beyond the scope of this diff.

Suggestions for future work:

  • Some files in gui/common should probably be moved elsewhere
  • Template loading code is duplicated
  • The gamesetup code still needs work for proper UI/logic separation.

Help & comments by: smiley

Reported by: vladislav / Langbart

Fixes #6513

Differential Revision:

Note: See TracTickets for help on using tickets.