widelands / widelands

Widelands is a free, open source real-time strategy game with singleplayer campaigns and a multiplayer mode. The game was inspired by Settlers II™ (© Bluebyte) but has significantly more variety and depth to it.
https://www.widelands.org/
GNU General Public License v2.0
1.99k stars 154 forks source link

Assertion failure in game host on desync #6247

Closed bunnybot closed 9 months ago

bunnybot commented 9 months ago

tothxaMirrored from Codeberg Created on Tue Nov 28 23:21:22 CET 2023 by Tóth András (tothxa)


Describe the bug When a desync happens due to some local script on the host, it causes an is_initializer_thread() assertion failure in UI::Panel::do_redraw_now().

To reproduce Steps to reproduce the behavior:

  1. Start a local multiplayer game with a debug build hosting
  2. Use ctrl+shift+backspace for cheating mode in the host
  3. Change the amount of some ware in the HQ
  4. See error

Expected behavior The desync should be caught cleanly, like when the client does the same cheating.

Version:

Additional context With #6182, using a realtime sleep in the lua console makes the host segfault in do_redraw_now() with a release build. Not sure if it's an actual problem there (shouldn't be, the realtime stuff is just copied from the existing gametime counterparts) or something in there just makes this problem visible. The debug build gives the same assertion failure as master.

stdout:

[00:03:07.363 real] ERROR: [Host]: lost synchronization with client 0 at time 11065!
[00:03:07.363 real] ERROR: I have:     eaf98455bd62457f4cbcc6a5210bde5a
[00:03:07.363 real] ERROR: Client has: b48e944ec0c392e881a477757fd2ee2f
[00:00:11.065 game] ERROR: Error: A desync occurred but no filename for the syncstream has been set.
[00:03:07.891 real] ERROR: ##############################
[00:03:07.891 real] ERROR:   FATAL EXCEPTION: CLIENT_DESYNCED
[00:03:07.891 real] ERROR: ##############################
[00:03:07.891 real] ERROR:   Please report this problem to help us improve Widelands.
[00:03:07.891 real] ERROR:   You will find related messages in the standard output (stdout.txt on Windows).
[00:03:07.891 real] ERROR:   You are using version 1.2~git26377 (9d5f67c@master) Debug.
[00:03:07.891 real] ERROR:   Please add this information to your report.
[00:03:07.891 real] ERROR:   If desired, Widelands attempts to create an emergency savegame.
[00:03:07.891 real] ERROR:   It is often – though not always – possible to load it and continue playing.
[00:03:07.891 real] ERROR: ##############################
widelands-dbg: ../src/ui_basic/panel.cc:250: void UI::Panel::do_redraw_now(bool, const string&): Assertion `is_initializer_thread()' failed.
Aborted
bunnybot commented 9 months ago

NordfrieseMirrored from Codeberg On Wed Nov 29 12:28:07 CET 2023, Benedikt Straub (Nordfriese) wrote:


I cannot reproduce with 1.2~git26377 (9d5f67c@master) Debug

bunnybot commented 9 months ago

tothxaMirrored from Codeberg On Wed Nov 29 18:06:49 CET 2023, Tóth András (tothxa) wrote:


That's strange. I can also reproduce it if Widelands is built with clang-13 in buster or gcc 12.2 in bookworm. The original one was gcc 8.3 in buster.

bunnybot commented 9 months ago

tothxaMirrored from Codeberg On Fri Dec 01 14:40:02 CET 2023, Tóth András (tothxa) wrote:


With this patch, I get this backtrace (plus a segfault???):

[00:01:27.154 real] ERROR: [Host]: lost synchronization with client 0 at time 32669!
[00:01:27.154 real] ERROR: I have:     3520b996baabc2bd021d88c1eca40017
[00:01:27.154 real] ERROR: Client has: a34c0f23c4ff02fa570f6487e3db4d61
[00:00:32.669 game] ERROR: Error: A desync occurred but no filename for the syncstream has been set.
[00:01:27.317 real] ERROR: ##############################
[00:01:27.317 real] ERROR:   FATAL EXCEPTION: CLIENT_DESYNCED
[00:01:27.317 real] ERROR: ##############################
[00:01:27.317 real] ERROR:   Please report this problem to help us improve Widelands.
[00:01:27.317 real] ERROR:   You will find related messages in the standard output (stdout.txt on Windows).
[00:01:27.317 real] ERROR:   You are using version 1.2~git26385 (781a138@master) Release.
[00:01:27.317 real] ERROR:   Please add this information to your report.
[00:01:27.317 real] ERROR:   If desired, Widelands attempts to create an emergency savegame.
[00:01:27.317 real] ERROR:   It is often – though not always – possible to load it and continue playing.
[00:01:27.317 real] ERROR: ##############################
src/widelands-master/widelands-xx(_ZN2UI5Panel13do_redraw_nowEbRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x246)[0x5626a8fac636]
src/widelands-master/widelands-xx(_ZN2UI14ProgressWindow18try_set_backgroundERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x142)[0x5626a8fac912]
src/widelands-master/widelands-xx(_ZN2UI14ProgressWindow14set_backgroundERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x3a)[0x5626a8facaaa]
src/widelands-master/widelands-xx(_ZN2UI14ProgressWindowC1EPNS_5PanelERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_b+0x1cc)[0x5626a8facddc]
src/widelands-master/widelands-xx(_ZN9Widelands14EditorGameBase16create_loader_uiERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EEbRKS7_SD_bPN2UI5PanelE+0x4b)[0x5626a903441b]
src/widelands-master/widelands-xx(_ZN13WLApplication14emergency_saveEPN2UI5PanelERN9Widelands4GameERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEhbb+0x7f8)[0x5626a90e0cc8]
src/widelands-master/widelands-xx(_ZN8GameHost17disconnect_clientEjRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbS7_+0x4ce)[0x5626a8ffce9e]
src/widelands-master/widelands-xx(_ZN8GameHost18check_sync_reportsEv+0x271)[0x5626a8ffd271]
src/widelands-master/widelands-xx(_ZN9Widelands8CmdQueue9run_queueERK8DurationR4Time+0x11c)[0x5626a8d4a78c]
src/widelands-master/widelands-xx(_ZN9Widelands4Game5thinkEv+0x10e)[0x5626a902ac6e]
src/widelands-master/widelands-xx(_ZN15InteractiveBase16game_logic_thinkEv+0x163)[0x5626a8f07e93]
src/widelands-master/widelands-xx(_ZN2UI5Panel12logic_threadEv+0x82)[0x5626a8fa2cf2]
/lib/x86_64-linux-gnu/libstdc++.so.6(+0xbbb2f)[0x7fd526a6eb2f]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x7fa3)[0x7fd526ba5fa3]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7fd52674f06f]

##############################
FATAL ERROR: Received signal 11 (Segmentation fault)
Backtrace:
src/widelands-master/widelands-xx(+0x7594ab)[0x5626a90b04ab]
/lib/x86_64-linux-gnu/libc.so.6(+0x37970)[0x7fd52668d970]
src/widelands-master/widelands-xx(_ZN17InteractivePlayer13draw_map_viewEP7MapViewP12RenderTarget+0x881)[0x5626a8f050b1]
src/widelands-master/widelands-xx(_ZN2UI5Panel13do_draw_innerER12RenderTarget+0x10)[0x5626a8f92070]
src/widelands-master/widelands-xx(_ZN2UI5Panel7do_drawER12RenderTarget+0x13b)[0x5626a8f9171b]
src/widelands-master/widelands-xx(_ZN2UI5Panel13do_redraw_nowEbRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0xbf)[0x5626a8fac4af]
src/widelands-master/widelands-xx(_ZN2UI5Panel6do_runEv+0x3eb)[0x5626a8fad31b]
src/widelands-master/widelands-xx(_ZN9Widelands4Game3runENS0_13StartGameTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_+0x489)[0x5626a90358b9]
src/widelands-master/widelands-xx(_ZN8GameHost12run_callbackEv+0xda9)[0x5626a8fff6c9]
src/widelands-master/widelands-xx(_ZN6FsMenu9LaunchMPG10clicked_okEv+0xa5)[0x5626a8f82745]
src/widelands-master/widelands-xx(+0x72f07e)[0x5626a908607e]
src/widelands-master/widelands-xx(_ZN2UI6Button19handle_mousereleaseEhii+0x85)[0x5626a8fa1085]
src/widelands-master/widelands-xx(_ZN2UI5Panel15ui_mousereleaseEhii+0x83)[0x5626a8f91303]
src/widelands-master/widelands-xx(_ZN13WLApplication12handle_inputEPK13InputCallback+0x3ce)[0x5626a90c307e]
src/widelands-master/widelands-xx(_ZN2UI5Panel6do_runEv+0x37f)[0x5626a8fad2af]
src/widelands-master/widelands-xx(_ZN6FsMenu8MainMenu9main_loopEv+0x2f)[0x5626a8f6bd1f]
src/widelands-master/widelands-xx(_ZN13WLApplication3runEv+0x148)[0x5626a90e25c8]
src/widelands-master/widelands-xx(main+0xa3)[0x5626a8c374e3]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xeb)[0x7fd52667a09b]
src/widelands-master/widelands-xx(_start+0x2a)[0x5626a8c3785a]
bunnybot commented 9 months ago

frankystoneMirrored from Codeberg On Fri Dec 01 16:31:35 CET 2023, (frankystone) wrote:


I can reproduce this. Settings are:

When changing a ware (Granit + 1) it last ~1sec until the desync happen.

[00:01:10.588 real] ERROR: [Host]: lost synchronization with client 0 at time 20267!
[00:01:10.588 real] ERROR: I have:     98b1b0418f05a3a395011b1366d9d782
[00:01:10.588 real] ERROR: Client has: 4cf2e051d8c6d3c876edd91806481856
[00:00:20.267 game] ERROR: Error: A desync occurred but no filename for the syncstream has been set.
[00:01:10.616 real] ERROR: ##############################
[00:01:10.616 real] ERROR:   FATAL EXCEPTION: CLIENT_DESYNCED
[00:01:10.616 real] ERROR: ##############################
[00:01:10.616 real] ERROR:   Please report this problem to help us improve Widelands.
[00:01:10.616 real] ERROR:   You will find related messages in the standard output (stdout.txt on Windows).
[00:01:10.616 real] ERROR:   You are using version 1.2~git26380 (6712f0f@master) Debug.
[00:01:10.616 real] ERROR:   Please add this information to your report.
[00:01:10.616 real] ERROR:   If desired, Widelands attempts to create an emergency savegame.
[00:01:10.616 real] ERROR:   It is often – though not always – possible to load it and continue playing.
[00:01:10.616 real] ERROR: ##############################
widelands: /home/kaputtnik/Quellcode/widelands-repo/v1.2/src/ui_basic/panel.cc:250: void UI::Panel::do_redraw_now(bool, const std::string&): Assertion `is_initializer_thread()' failed.
Abgebrochen (Speicherabzug geschrieben)
bunnybot commented 9 months ago

Assigned to tothxa

bunnybot commented 9 months ago

tothxaMirrored from Codeberg On Fri Dec 01 21:35:46 CET 2023, Tóth András (tothxa) wrote:


I think I can have a shot at solving this, based on the backtrace…