The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: Dwachs on September 18, 2022, 12:53:54 PM

Title: Assertion failed when closing network game
Post by: Dwachs on September 18, 2022, 12:53:54 PM
CLosing the window of a running network game throws this:
sim-gitsvn: src/simutrans/utils/simrandom.cc:103: uint32 simrand(uint32): Assertion `(random_origin&INTERACTIVE_RANDOM) == 0' failed.

Thread 1 "sim-gitsvn" received signal SIGABRT, Aborted.
0x00007ffff6229cdb in raise () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ffff6229cdb in raise () from /lib64/libc.so.6
#1  0x00007ffff622b375 in abort () from /lib64/libc.so.6
#2  0x00007ffff6221cda in __assert_fail_base () from /lib64/libc.so.6
#3  0x00007ffff6221d62 in __assert_fail () from /lib64/libc.so.6
#4  0x000000000074d970 in simrand (max=<optimized out>) at src/simutrans/utils/simrandom.cc:103
#5  0x0000000000704076 in haltestelle_t::fetch_goods (this=<optimized out>, load=..., good_category=<optimized out>,
    requested_amount=3, destination_halts=...) at src/simutrans/simhalt.cc:2094
#6  0x00000000007647b1 in vehicle_t::load_cargo (this=this@entry=0x63db710, halt=..., halt@entry=...,
    destination_halts=..., max_amount=<optimized out>) at src/simutrans/vehicle/vehicle.cc:181
#7  0x00000000006e85c9 in convoi_t::hat_gehalten (this=0x63db130, halt=...) at src/simutrans/simconvoi.cc:3026
#8  0x00000000006ff00e in haltestelle_t::request_loading (this=0x4a1b9a0, cnv=...) at src/simutrans/simhalt.cc:925
#9  0x00000000006e34f3 in convoi_t::laden (this=this@entry=0x63db130) at src/simutrans/simconvoi.cc:2828
#10 0x00000000006ed799 in convoi_t::step (this=0x63db130) at src/simutrans/simconvoi.cc:1193
#11 0x0000000000792af8 in karte_t::step (this=this@entry=0x4a5c330) at src/simutrans/world/simworld.cc:3248
#12 0x00000000007938a6 in karte_t::interactive (this=this@entry=0x4a5c330, quit_month=quit_month@entry=2147483647)
    at src/simutrans/world/simworld.cc:6177
#13 0x0000000000713e97 in simu_main (argc=argc@entry=9, argv=argv@entry=0x7fffffffdb88)
    at src/simutrans/simmain.cc:1677
#14 0x00000000007171a9 in sysmain (argc=9, argv=0x7fffffffdb88) at src/simutrans/sys/simsys.cc:1156
#15 0x00000000007dac54 in main (argc=<optimized out>, argv=<optimized out>) at src/simutrans/sys/simsys_s2.cc:1185

Title: Re: Assertion failed when closing network game
Post by: Dwachs on September 22, 2022, 07:58:46 AM
same reason as in

https://forum.simutrans.com/index.php/topic,21928

INT_CHECK is called from somewhere, the quit-event is processed, which disables network mode. This prevents the random-mode to be reset in siminteraction, further down the assertion is triggered.

Honestly, I think calling check_events in sync_step is a bad idea.
Title: Re: Assertion failed when closing network game
Post by: prissi on September 22, 2022, 11:49:34 PM
Processing the events more frequently was necessary due to the broken way SDL handles finger events. Touching the screen fires between 50-100 identical event events (especially considering also the  useless floating point precision of my finger with at best 10 dpi compared to the integer values of an 8000 dpi mouse ... ) In the step, then often only once every second events were processed, making Simutrans unuseable.

So moving back is not really an option on weak devices like ARM.

EDIT: The quit event does call the quit tool in r10754, which is not safegame save and thus only executed in a step().
Title: Re: Assertion failed when closing network game
Post by: Dwachs on September 23, 2022, 11:21:18 AM
The reason, why tool_quit was set to network-safe, was that quitting client will not send the quit command over network. Also in network games, no password should be needed to quit a game as client.

I did not test, but I suspect that with this change a clitting client will quit the server, too.

Edit: Tested. Closing the client sends a quit command to the server.
Title: Re: Assertion failed when closing network game
Post by: Dwachs on September 23, 2022, 02:56:49 PM
I think we need another property for tools that prevents that they are send via network. This applies to quit, load/save functions.
Title: Re: Assertion failed when closing network game
Post by: prissi on September 24, 2022, 12:58:25 PM
Setting the local flag for local only commands does the trick in r10758. Still need the proper tools for loading.
Title: Re: Assertion failed when closing network game
Post by: Dwachs on September 25, 2022, 09:10:12 AM
Thanks for looking into this. Sorry for bringing this up once more:

When closing the server window (with one client connected) still triggers the assertion for the server.
Title: Re: Assertion failed when closing network game
Post by: Dwachs on October 27, 2022, 08:27:18 PM
I hope this is fixed with r10790.