Page 1 of 1

[0.15.28] Command API causes desyncs.

Posted: Sun Jul 09, 2017 5:01 pm
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.

Re: [0.15.28] Command API causes desyncs.

Posted: Sun Jul 09, 2017 5:24 pm
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.

Re: [0.15.28] Command API causes desyncs.

Posted: Sun Jul 09, 2017 7:03 pm
by Valansch
Thank you for your quick reply on a sunday.
And sorry for wasting your time.

Have a nice day.