[0.15.28] Command API causes desyncs.

Place to get help with not working mods / modding interface.
Valansch
Inserter
Inserter
Posts: 23
Joined: Fri Jun 23, 2017 12:00 pm
Contact:

[0.15.28] Command API causes desyncs.

Post by Valansch »

Whenever a player on hour server is using certain custom commands implemented by me, a certain set of players will desync. Meaning the same commands will reproducibly desync the same set of players.

I know desyncs related to user scripts won't be investigated unless proven that the dsync is not caused by the script. But I beg you to hear me out. I have several clues that make me believe the bug is in the commands API.
  • 1. I have two commands (/mods and /regulars), which are implemented identically. The only difference is the variable that will be accessed. Code was actually copied, pasted and search & replaced. But /regulars caused desyncs, while /mods worked fine.

    2. After a server restart the commands desync behavior will change. Meaning certain other commands will cause a set of certain other placers to desync. But the scripts that would have caused the desync earlier (like /regulars) will no longer cause desyncs and work fine.

    3. I have found cpp exceptions in the logs. I don't know if that's relevant or not.

    (4. This is probably caused by one of my drivers and not factorio, but I thought mentioning won't hurt. 5 seconds after using a desyncing command I got a bluescreen. But if I have a driver issue personally, that couldn't have caused the desyncs, because the desync behavior is identical for all players on the server.)
I will do additional testing later, but can't promise results, since I can't subject a 30 player server to desync testing. The desyncs might not happen with fewer people online.


I have attacked 3 logs: The log of the client using the command causing the desync (in this case /regulars). The log of on the "victims" of the desync. And the server log.
One example of desyncs is at the following moment: (11759.674 in the client.log, 219.820 in the victim log, 718.910 in the server log)
I have also attached the files involved.

If you have any questions, need more files or want me to try/test something, i will gladly help you.
Attachments
control.lua
Control only for require
(69 Bytes) Downloaded 72 times
user_groups.lua
A file containing code called by the commands
(1.29 KiB) Downloaded 64 times
chatlog.lua
A file containing code called by the commands
(2.82 KiB) Downloaded 63 times
custom_commands.lua
The main file containing the commands
(8.15 KiB) Downloaded 63 times
server-current.log
The server log
(47.23 KiB) Downloaded 60 times
victim.log
The victims log
(294.04 KiB) Downloaded 67 times
client.log
The client logs
(4.43 MiB) Downloaded 62 times
Admin and Developer for RedMew
Rseding91
Factorio Staff
Factorio Staff
Posts: 16016
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.15.28] Command API causes desyncs.

Post by Rseding91 »

Your custom commands desync because you're not storing your data in the global table and it doesn't get persisted when someone joins in MP or through server restarts.

Code: Select all

local mods = {
	sanctorio = "",
}

local regulars = {
	helpower2 = "",
}
1. Player A joins the game
2. Player A is added to regulars
3. Player B joins the game
4. Player A runs /regulars

In this scenario player A will get his name + the default value and player B will get just the default value and it desyncs. You need to store any variables you mutate in the global table so they're persisted between save/load.

I'm going to move this to modding help.
If you want to get ahold of me I'm almost always on Discord.
Valansch
Inserter
Inserter
Posts: 23
Joined: Fri Jun 23, 2017 12:00 pm
Contact:

Re: [0.15.28] Command API causes desyncs.

Post by Valansch »

Thank you for your quick reply on a sunday.
And sorry for wasting your time.

Have a nice day.
Admin and Developer for RedMew
Post Reply

Return to “Modding help”