Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem deserializing byte array - InvalidOperationException caused by Decoders.InvalidArrayHeader.Read call #337

Open
flcrew opened this issue Feb 26, 2020 · 4 comments

Comments

@flcrew
Copy link

flcrew commented Feb 26, 2020

Hi together,

I'm facing a sporadic issue in my C# program deserializing a byte array using MessagePack.

When deserializing the following bytes

D9-A4-67-EC-F4-D4-79-4D-D5-A5-9A-1B-F7-14-50-65-48-69-00-00-94-C0-14-C0-0A-00-39-00-38-00-37-00-36-00-88-00-87-00-86-00-85-C0-19-00-3A-00-89-C0-0F-C0-05-00-35-00-84-C0-13-C0-09-00-33-00-32-00-31-00-30-00-9A-00-99-00-98-00-97-00-45-00-44-00-43-00-42-C0-18-00-34-00-9B-00-46-C0-0E-C0-04-00-2F-00-96-00-41-00-07-C0-11-C0-07-C0-16-00-18-C0-0C-C0-02-00-05-00-04-C0-12-C0-08-00-16-00-13-00-10-00-0D-C0-17-00-1B-C0-0D-C0-03-00-0A-00-15-00-12-00-0F-00-0C

I will get an InvalidOperationException "code is invalid. code:217 format:str 8".

Do you have a clue what may be the reason for this exception?
May it be a scrambled / not well transmitted message containing not all relevant deserialization data? (we are using NetMQ / sockets as underlying communication mechanism)
Is it possible that somehow the wrong decoder was chosen internally?

Call stack is:
MessagePack.dll!MessagePack.Decoders.InvalidArrayHeader.Read(byte[] bytes, int offset, out int readSize) Line 3543
MessagePack.dll!MessagePack.MessagePackBinary.ReadArrayHeader(byte[] bytes, int offset, out int readSize) Line882
MessagePack.Resolvers.DynamicUnionResolver!MessagePack.Formatters.CQRS_Messages_INetMesaageFormatter2.Deserialize(byte[] value, int value, MessagePack.IFormatterResolver value, ref int value)
MessagePack.dll!MessagePack.MessagePackSerializer.Deserialize<CQRS.Messages.INetMessage>(byte[] bytes, MessagePack.IFormatterResolver resolver) Line133
MessagePack.dll!MessagePack.MessagePackSerializer.Deserialize<CQRS.Messages.INetMessage>(byte[] bytes) Line124

Thanks in advance!

Dennis

@DylanGTech
Copy link

I have this exact same problem. Stinks to know there is no response after this long. For me, it was ValueTuble<string, string> type this happened to, on .NET Core

@flcrew
Copy link
Author

flcrew commented Sep 14, 2020

We finally found the reason for this issue - it was not caused by MessagePack itself, but by faulty handling of our program. It actually injected data into the deserializer that was not originally serialized with MessagePack. Maybe it could be a hint for you to check if the data was really serialized with MessagePack beforehand.

@DylanGTech
Copy link

I now suspect that I may be doing something similar. I realize now that NetworkStreams can only have one thread for reading, and one for writing. Fixed that and this issue largely went away. Although when I try to use a MessagePackStreamReader on the client, I get issues where I only get a few bytes, nothing that can be deserialized. I'm looking into that now. Thanks!

@yfakariya
Copy link
Member

I am sorry to leave this issue open and did not comment it for a long time, and I appreciate you to communicate each other to share your experience to solve the problem!

But as I can see, the above stack trace looks another library -- so, this issue should be discussed on another repo.

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

No branches or pull requests

3 participants