-
-
Notifications
You must be signed in to change notification settings - Fork 673
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
Fix deserialization of big files #940
Fix deserialization of big files #940
Conversation
Holy cow, that would be a huge stream. Thanks for submitting a fix, but this would still leave MessagePack trying to allocate potentially a 4GB area of contiguous memory, which may be problematic as well. On a 64-bit process this might be feasible, but in a 32-bit process, even finding 1GB of contiguous memory may be unlikely. I think instead of this particular change, we should simply set a reasonable cap (somewhere between 80KB and 1MB perhaps) on how large the arg is to |
It looks like the loop is already there, so if we just use |
Did you mean Math.Min? Because right now we are trying to cast long value to int and getting arithmetic exception. That ruins the deserialization completely(you can serialize file of that size, but cannot deserialize). |
I checked the code and profile it. It seems it is already using the chunks of size: |
limiting the size of Hint, fix async version of Deserialize
@AArnott updated the PR. Found that between 0x7FFFFFC7 and int.MaxValue things still not work because of the array of bytes length limit, so I added the limit to the HintSize as you suggested (not sure that it's in the right place though). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As commented, please revert the change to Sequence<T>
and apply the fix to MessagePackSerializer
itself to avoid asking for egregiously large spans.
src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/Sequence`1.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thank you.
This is a fix for deserialization of files with Length more than int.MaxValue.