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

The Input class changes its buffer when deserialize a string #1054

Open
NPE0 opened this issue Mar 5, 2024 · 2 comments
Open

The Input class changes its buffer when deserialize a string #1054

NPE0 opened this issue Mar 5, 2024 · 2 comments

Comments

@NPE0
Copy link

NPE0 commented Mar 5, 2024

Describe the bug
kryo 4...
When I use a single byte[] array to deserialize from multiple streams, sometimes there is a crash with the error

com.esotericsoftware.kryo.kryo5.io.KryoBufferUnderflowException: Buffer underflow

This is a real scenario when using a cache that contains data shared between threads.
As I see, it is a known problem in readAscii method. Because it was fixed in 5.. version of the library.
But I think it will be good to fix it in 4... version family too.

At the moment, I fixed this by simply copying the input array to a new one.
In terms of cost, this is similar to using an intermediate char[] buffer in "readAscii"

To Reproduce
I wrote a test that reproduces the situation. See "*Additional context".

Environment:

  • JDK Version: [1.8]
  • Kryo Version: [4.0.2]

Additional context
KryoBugLab.zip

@theigl
Copy link
Collaborator

theigl commented Mar 5, 2024

Is the fix backwards compatible? If it is, you could provide a PR that backports it to Kryo 4.

I don't actively maintain Kryo 4 anymore, but if users provide fixes, I can do a release.

@mrniko
Copy link

mrniko commented Apr 5, 2024

Getting same issue with the latest Kryo version

Caused by: com.esotericsoftware.kryo.io.KryoBufferUnderflowException: Buffer underflow.
	at com.esotericsoftware.kryo.io.Input.require(Input.java:221)
	at com.esotericsoftware.kryo.io.Input.readVarInt(Input.java:447)
	at com.esotericsoftware.kryo.util.DefaultClassResolver.readClass(DefaultClassResolver.java:145)
	at com.esotericsoftware.kryo.Kryo.readClass(Kryo.java:758)
	at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:869)
	at org.redisson.codec.Kryo5Codec$4.decode(Kryo5Codec.java:153)
	at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:454)
	at org.redisson.client.handler.CommandDecoder.decodeCommandBatch(CommandDecoder.java:308)
	at org.redisson.client.handler.CommandDecoder.decodeCommand(CommandDecoder.java:234)
	at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:150)
	at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:126)
	at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection

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

No branches or pull requests

3 participants