DarkRift icon indicating copy to clipboard operation
DarkRift copied to clipboard

Message.Serialize has unpredicatable behaviour

Open JamJar00 opened this issue 7 years ago • 3 comments

Quick Description

Invoking Message.Serialize(DarkRiftWriter) only sets a reference to the backing array of the DarkRiftWriter.

Explaination

Given the above, if the writer was then written to the data in the message would change. However, if enough data was written to the writer to cause the backing array to resize these changes would not propagate to the message and the message would hold a reference to out of date data.

Consistency needs to be formed here however this is resolved.

JamJar00 avatar Mar 04 '18 21:03 JamJar00

This has been fixed in version 2.4.0. Since an AutoRecyclingArray is now passed as the reference and that can be resized without changing the reference this is no longer an issue.

JamJar00 avatar Mar 03 '19 14:03 JamJar00

Reopening as this is still not working.

Now however, the reference will always point to the latest data, but the count and offset aren't synchronised across the Serialize boundary. This is probably something that is not easily fixed without a re-architecture.

JamJar00 avatar Mar 29 '19 22:03 JamJar00

This can probably be fixed fairly easily by making the AutoRecyclingArray in DarkRift do the resizing rather than the MessageBuffer itself.

JamJar00 avatar Feb 07 '21 15:02 JamJar00