Anonymous Login
2017-11-21 14:57 CET

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0001109OpenClonkEngine - Networkpublic2017-08-05 11:06
ReporterJan 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusacknowledgedResolutionopen 
Product Version 
Target Version8.0Fixed in Version 
Summary0001109: Sync loss on runtime join
DescriptionFinally I found a way to reliably trigger the runtime join sync loss in Clonk Rage and OpenClonk.
Steps To ReproduceYou just have to constantly create control data which affects the values compared in the sync checks. The easiest value to modify is Rnc (RandomCount).
In
C4Game::Execute()
, write
if (Network.isHost()) ::Control.DoInput(CID_Script, new C4ControlScript("Random(100)", 
C4ControlScript::SCOPE_Console), CDT_Queue);
to the line above
EXEC_S(     ExecObjects();                    , ExecObjectsStat )
Additional Information- Control rate must be set to at least 2.
-
eDelivery
of
C4GameControl::DoInput()
has to be
CDT_Queue
.
CDT_Sync
does not cause sync loss.
- The bug was introduced somewhere between Clonk Rage 4.9.9.7 [312] and 4.9.10.1 [318], since runtime join still works in [312], but desyncs in [318]. I didn't test the versions between them since I couldn't obtain these versions.
TagsNo tags attached.
Attached Files
  • patch file icon 0001-Workaround-for-runtime-join-desync.patch (1,432 bytes) 2015-12-02 14:40 -
    From 323240c6cf29e2e3cfcb9b8e9af6b1af19005099 Mon Sep 17 00:00:00 2001
    From: Jan Heberer <jangc@t-online.de>
    Date: Wed, 2 Dec 2015 14:38:58 +0100
    Subject: [PATCH] Workaround for runtime join desync
    
    Reconstruct a part of C4GameControlNetwork::PackCompleteCtrl from Clonk Rage [312] disassembly. This will fix a bug where a control packet is executed twice if it was received twice.
    ---
     src/network/C4GameControlNetwork.cpp | 15 ++++-----------
     1 file changed, 4 insertions(+), 11 deletions(-)
    
    diff --git a/src/network/C4GameControlNetwork.cpp b/src/network/C4GameControlNetwork.cpp
    index a432464..9903ec5 100644
    --- a/src/network/C4GameControlNetwork.cpp
    +++ b/src/network/C4GameControlNetwork.cpp
    @@ -775,17 +775,10 @@ C4GameControlPacket *C4GameControlNetwork::PackCompleteCtrl(int32_t iTick)
     	// pack everything in ID order (client list is ordered this way)
     	C4GameControlPacket *pCtrl;
     	for (pClient = pClients; pClient; pClient = pClient->pNext)
    -		while (pClient->getNextControl() <= iTick)
    -		{
    -			// get control
    -			int32_t iNextControl = pClient->getNextControl();
    -			pCtrl = getCtrl(pClient->getClientID(), iNextControl);
    -			if (!pCtrl) break;
    -			pClient->SetNextControl(iNextControl + 1);
    -			assert(pCtrl);
    -			// add
    -			pComplete->Add(*pCtrl);
    -		}
    +	{
    +		pCtrl = getCtrl(pClient->getClientID(), iTick);
    +		if (pCtrl) pComplete->Add(*pCtrl);
    +	}
     
     	// add to list
     	AddCtrl(pComplete);
    -- 
    2.6.3.windows.1
    
    
    patch file icon 0001-Workaround-for-runtime-join-desync.patch (1,432 bytes) 2015-12-02 14:40 +
  • patch file icon 0001-Fix-sync-loss-on-runtime-join-in-decentral-network-mode.patch (1,814 bytes) 2016-01-02 23:08 -
    From d976a6ba1b2ffd23f0ece7deeb08b4c49ec1d0ee Mon Sep 17 00:00:00 2001
    From: Jan Heberer <jangc@t-online.de>
    Date: Sat, 2 Jan 2016 22:59:08 +0100
    Subject: [PATCH] Fix sync loss on runtime join in decentral network mode
    
    ---
     src/network/C4GameControlNetwork.cpp | 28 +++++++++++++++++++++-------
     1 file changed, 21 insertions(+), 7 deletions(-)
    
    diff --git a/src/network/C4GameControlNetwork.cpp b/src/network/C4GameControlNetwork.cpp
    index a432464..6a59a96 100644
    --- a/src/network/C4GameControlNetwork.cpp
    +++ b/src/network/C4GameControlNetwork.cpp
    @@ -773,19 +773,33 @@ C4GameControlPacket *C4GameControlNetwork::PackCompleteCtrl(int32_t iTick)
     	pComplete->Set(C4ClientIDAll, iTick);
     
     	// pack everything in ID order (client list is ordered this way)
    -	C4GameControlPacket *pCtrl;
    -	for (pClient = pClients; pClient; pClient = pClient->pNext)
    -		while (pClient->getNextControl() <= iTick)
    +	if (eMode == CNM_Async)
    +	{
    +		for (pClient = pClients; pClient; pClient = pClient->pNext)
    +		{
    +			while (pClient->getNextControl() <= iTick)
    +			{
    +				// get control
    +				int32_t iNextControl = pClient->getNextControl();
    +				C4GameControlPacket *pCtrl = getCtrl(pClient->getClientID(), iNextControl);
    +				if (!pCtrl) break;
    +				pClient->SetNextControl(iNextControl + 1);
    +				// add
    +				pComplete->Add(*pCtrl);
    +			}
    +		}
    +	}
    +	else
    +	{
    +		for (pClient = pClients; pClient; pClient = pClient->pNext)
     		{
     			// get control
    -			int32_t iNextControl = pClient->getNextControl();
    -			pCtrl = getCtrl(pClient->getClientID(), iNextControl);
    -			if (!pCtrl) break;
    -			pClient->SetNextControl(iNextControl + 1);
    +			C4GameControlPacket *pCtrl = getCtrl(pClient->getClientID(), iTick);
     			assert(pCtrl);
     			// add
     			pComplete->Add(*pCtrl);
     		}
    +	}
     
     	// add to list
     	AddCtrl(pComplete);
    -- 
    2.6.4.windows.1
    
    

-Relationships
+Relationships

-Notes

~0003094

Sven2 (developer)

This is very interesting. Have you checked whether the controls between different clients are in the same order in the resulting records? (i.e..: Convert host and client record to text file using rec dump and then just compare).

~0004181

Clonkonaut (developer)

Is this still an issue?

~0004200

ala (developer)

As far as we tested, runtime join doesn't work currently.

~0004204

Clonkonaut (developer)

Yes, runtime join in general. I was asking about this specific bug.

~0004207

Jan (reporter)

Yes, the bug is still present. There is only a workaround (which I'm currently using in Clonk Rage) but no real solution yet.

~0004214

Clonkonaut (developer)

Could you share this workaround?

~0004231

Jan (reporter)

I attached the workaround to the bug report.

~0004450

Jan (reporter)

Uploaded new patch. This is the real fix, not only a workaround like the one before.

~0004457

Clonkonaut (developer)

I have created a corresponding thread in the forum:

http://forum.openclonk.org/topic_show.pl?tid=3229

~0004498

PeterW (developer)

See forum - this patch is probably on the right track, but still quite symptomatic. The "proper way" here would be:

1. Correct which control packets we expect - this boils down to setting the next control ticks for runtime clients correctly in C4GameControlNetwork::AddClient (add +1?). Note that this would have to check whether it's a runtime join, as normal joins definitely want the unchanged start control tick in that space.

2. Figure out why the surplus control gets produced in the first place - jumping over control packets is a big no-no, as it might have stuff like player joins that might get stuck. This is probably going to be a fairly similar change to the one above, but concerning C4GameControlNetwork::SetActivated: For runtime joins (!) you might have to remove the "-1" here.

And then pray to god that savegame resumes didn't break again...

~0004506

PeterW (developer)

Hm, your method doesn't seem to be enough to cause desyncs with OC for me. Can you describe exactly what you did - e.g. network configuration, sync check rate and scenario?
+Notes

-Issue History
Date Modified Username Field Change
2014-09-03 21:01 Jan New Issue
2014-09-04 22:36 Sven2 Note Added: 0003094
2015-10-16 02:33 Sven2 Target Version => 7.0
2015-11-30 13:39 Clonkonaut Note Added: 0004181
2015-11-30 13:39 Clonkonaut Status new => feedback
2015-11-30 16:54 ala Note Added: 0004200
2015-11-30 18:12 Clonkonaut Note Added: 0004204
2015-11-30 21:27 Jan Note Added: 0004207
2015-11-30 21:27 Jan Status feedback => new
2015-12-01 11:45 Clonkonaut Note Added: 0004214
2015-12-02 14:40 Jan File Added: 0001-Workaround-for-runtime-join-desync.patch
2015-12-02 14:41 Jan Note Added: 0004231
2016-01-02 20:44 Clonkonaut Status new => acknowledged
2016-01-02 20:44 Clonkonaut Target Version 7.0 => 7.1 (Bugfix update)
2016-01-02 23:08 Jan File Added: 0001-Fix-sync-loss-on-runtime-join-in-decentral-network-mode.patch
2016-01-02 23:09 Jan Note Added: 0004450
2016-01-04 11:18 Clonkonaut Note Added: 0004457
2016-01-09 01:35 PeterW Note Added: 0004498
2016-01-09 20:53 PeterW Note Added: 0004506
2017-08-05 11:06 Maikel Target Version 7.1 (Bugfix update) => 8.0
+Issue History