kotlinx-io icon indicating copy to clipboard operation
kotlinx-io copied to clipboard

Getting buffer overflow randomly in tests

Open altavir opened this issue 6 years ago • 1 comments
trafficstars

I am getting

java.nio.BufferOverflowException
	at java.base/java.nio.Buffer.nextPutIndex(Buffer.java:662)
	at java.base/java.nio.HeapByteBuffer.put(HeapByteBuffer.java:196)
	at kotlinx.io.core.IoBuffer.writeByte(IoBufferJVM.kt:164)
	at kotlinx.io.core.BytePacketBuilderBase.writeByte(Builder.kt:436)

in tests when I run a lot of tests simultaniously. When I run them individually, everything works fine. I tried to debug the problem, but it proved to be rather hard due to not always obvious borrowing logic. There is a check inside that should prevent this error, but is does not seem to work.

altavir avatar Sep 12 '19 06:09 altavir

It seems that the problem is caused by the fact that IOBuffers created by ByteReadPacket(array) (which have the wrong size) are randomly being disposed into default pool and then reused. I think it should be fixed in io-2.

altavir avatar Oct 27 '19 07:10 altavir

We're rebooting the kotlinx-io development (see https://github.com/Kotlin/kotlinx-io/issues/131), all issues related to the previous versions will be closed. Consider reopening it if the issue remains (or the feature is still missing) in a new version.

fzhinkin avatar Jun 12 '23 11:06 fzhinkin