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

ByteString.ToArray throws sometimes #3183

Closed
Aaronontheweb opened this issue Nov 2, 2017 · 6 comments
Closed

ByteString.ToArray throws sometimes #3183

Aaronontheweb opened this issue Nov 2, 2017 · 6 comments

Comments

@Aaronontheweb
Copy link
Member

Version: Akka.NET v1.3.2

This error is not stable, but here it is:

[ERROR][11/2/2017 3:03:37 PM][Thread 0018][[akka://demo/user/StatsD-%5BUdp-%3E127.0.0.1%3A8125%5D0/StreamSupervisor-12/Flow-0-0-unknown-operation#737196236]] Error in stage [UdpSink]: Provided index is outside the bounds of the buffer to copy to.
Parameter name: index
Cause: System.ArgumentOutOfRangeException: Provided index is outside the bounds of the buffer to copy to.
Parameter name: index
   at Akka.IO.ByteString.CopyTo(Byte[] buffer, Int32 index, Int32 count)
   at Phobos.Monitoring.StatsD.Streams.UdpSink.UdpSinkLogic.SendToSocket(ByteString bytes)
   at Akka.Streams.Implementation.Fusing.GraphInterpreter.Execute(Int32 eventLimit)

The ByteString was created via a ByteString.FromString operation earlier.

@Horusiath
Copy link
Contributor

Horusiath commented Nov 2, 2017

This will be hard to detect actually. Maybe use FsCheck to test ByteString.CopyTo? A longer solution is to build ByteString as a proper rope struct.

@Aaronontheweb
Copy link
Member Author

I think an FsCheck spec is a good way to go here.

@Horusiath
Copy link
Contributor

@Aaronontheweb is this actually an issue or can we close it?

@Aaronontheweb
Copy link
Member Author

I think we still need to keep it open for a bit, but it doesn't need to be part of the 1.3.3 milestone any longer.

@vasily-kirichenko
Copy link
Contributor

I think the bug is not in ByteString, but in the calling code, which passes wrong combination of buffer and index:

if (index < 0 || index >= buffer.Length) throw new ArgumentOutOfRangeException(nameof(index), "Provided index is outside the bounds of the buffer to copy to.");

@Aaronontheweb
Copy link
Member Author

@vasily-kirichenko I'll double check the code that threw it, but AFAIK I wasn't calling that method you linked directly. I was calling some of the higher level ByteString.FromString methods, which is where I think the bug might be.

@marcpiechura marcpiechura modified the milestones: 1.3.3, 1.4.0 Mar 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants