GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — System.OverflowException is thrown when LZ4MessagePackSerializer.Deserialize · Issue #1586 · MessagePack-CSharp/MessagePack-CSharp

System.OverflowException is thrown when LZ4MessagePackSerializer.Deserialize #1586

New issue
Copy link
New issue
Copy link
Closed
#1685
Closed
System.OverflowException is thrown when LZ4MessagePackSerializer.Deserialize#1586
#1685
Copy link

Description

@Halfason
Halfason
opened on Mar 31, 2023
Issue body actions

Bug description

Our team use LZ4MessagePackSerializer.Serialize to serialize objects to file.
And deserialize objects by using LZ4MessagePackSerializer.Deserialize.

But one day, when deserializing, an System.OverflowException is thrown.
Why doesn't it throw the exception when serializing and saving?

Repro steps

  using (Stream stream = File.OpenRead(fileName))
  {
      stream.Seek(0, SeekOrigin.Begin);
      var localFileData = LZ4MessagePackSerializer.Deserialize<T>(stream); //object
  }

Expected behavior

no exceptions are thrown.

Actual behavior

one System.OverflowException is thrown.

  • Version used: 1.9.0.0
  • Runtime: .NET Framework 4.5.2

Additional context

Exception Stacktrace:

System.OverflowException: 算术运算导致溢出。
在 MessagePack.LZ4.LZ4Codec.CheckArguments(Byte[] input, Int32 inputOffset, Int32 inputLength, Byte[] output, Int32 outputOffset, Int32 outputLength)
在 MessagePack.LZ4.LZ4Codec.Decode64Unsafe(Byte[] input, Int32 inputOffset, Int32 inputLength, Byte[] output, Int32 outputOffset, Int32 outputLength)
在 MessagePack.LZ4MessagePackSerializer.DeserializeCore[T](ArraySegment`1 bytes, IFormatterResolver resolver)
在 MessagePack.LZ4MessagePackSerializer.Deserialize[T](Stream stream, IFormatterResolver resolver, Boolean readStrict)

Activity

  1. AArnott commented on Apr 6, 2023

    @AArnott
    AArnott
    on Apr 6, 2023
    Collaborator
    More actions

    My best guess is your file was corrupted between being written and read. If you can provide a full repro that includes serializing and the failed deserialization we can investigate further.

  2. gosferano commented on Sep 26, 2023

    @gosferano
    gosferano
    on Sep 26, 2023
    More actions

    Hi. Our team encountered similar issue too. Using MessagePackSerializer.Typeless.Deserialize with MessagePackCompression.Lz4BlockArray throws in MessagePack.MessagePackSerializer.DeserializeFromSequenceAndRewindStreamIfPossible when underlying FileStream size is above int.MaxValue. Shall I provide you a repro project or is it enough to look into it? I could also open a new issue if it doesn't seem related enough.

    Used NuGet package version: 2.5.124.

    Stack trace:

    Unhandled exception. System.OverflowException: Arithmetic operation resulted in an overflow.
       at MessagePack.MessagePackSerializer.DeserializeFromSequenceAndRewindStreamIfPossible[T](Stream streamToRewind, MessagePackSerializerOptions options, ReadOnlySequence`1 sequence, CancellationToken cancellationToken)
       at MessagePack.MessagePackSerializer.Deserialize[T](Stream stream, MessagePackSerializerOptions options, CancellationToken cancellationToken)
       at MessagePack.MessagePackSerializer.Typeless.Deserialize(Stream stream, MessagePackSerializerOptions options, CancellationToken cancellationToken)
  3. AArnott commented on Sep 27, 2023

    @AArnott
    AArnott
    on Sep 27, 2023
    Collaborator
    More actions

    @gosferano You've come across a long to int cast that doesn't even need to be there. I've removed it, but as I don't have any 4GB+ streams to deserialize handy to test with, can you help validate it by trying out the build in the #1685 PR?

    Reacted by Gytis
  4. gosferano commented on Sep 28, 2023

    @gosferano
    gosferano
    on Sep 28, 2023
    More actions

    @AArnott I tried #1685 on repro project I had and the problem is fixed.

    Reacted by Andrew Arnott
  5. AArnott
    closed this as completedin #1685on Sep 28, 2023
  6. AArnott commented on Sep 28, 2023

    @AArnott
    AArnott
    on Sep 28, 2023
    Collaborator
    More actions

    Shipped in v2.5.129 to nuget.org.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.