Skip to content

Conversation

@gungun974
Copy link
Contributor

Few weeks ago I got someone that try my first release of ComputerCraft for BTA. There was a report for this person where my mod did make some Unexpected network error but after further test from my side, I didn't understand which mod was doing this and couldn't reproduce this bug.

Today on my personal server with only CC and Halplibe, this bug reoccurred but this time I was able to debug and find a fix.

From the error message it was appearing one of the BTA Packet didn't do it's job and did a partial read, since every packet are kind aligned to the same stream, if one one of them don't read everything, everything is unaligned and now we got packet that try to decode garbage.

For better understanding I did create a build of Halplibe to see exactly what was send and receive from the UniversalPacket and I found those strange result :

Here the server send 5 TurtleBrainClientMessage and you can see the amount of byte the buffer is sending. Here nothing is strange.
image

However on the client, we can clearly see one of those reception don't read the full content of what the server is sending which mean we left junk for other network process
image

It appear that dis.read(buffer, 0, length) or dis.read(buffer) don't guaranteed the read of length can be done in one operation since again it appear the stream don't fill with the necessary data in one write.

So after some try I found dis.readFully(buffer, 0, length fix everything and now I can't reproduce anymore on my server this error.

@gungun974
Copy link
Contributor Author

After this accident I would like to add to this I think this all issue of the read not reading everything even if the server clearly send everything can also affect PacketCustomPayload in BTA. I know this is not the bug tracker of BTA and also I did not do the same kind of test on this one but from what read does. I think sometime a network error processing could be occurred with the in.read(this.data) not fully read the sending raw bytes

image

@MartinSVK12 MartinSVK12 changed the title Fix network corrumption with bad processing of UniversalPacket Fix network corruption with bad processing of UniversalPacket Apr 26, 2025
@MartinSVK12 MartinSVK12 merged commit d33157e into Turnip-Labs:7.3 Apr 26, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants