-
Notifications
You must be signed in to change notification settings - Fork 829
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
Input.readAscii multithreaded bug #264
Comments
Have you read this on the main page? I think it is pretty clear about this issue. |
Btw this issue was recently discussed in #128. |
Ah! I did read through the documentation, but the byte[] part escaped me. I didn't even realize that I was calling the method with the same byte[] until I did lots of debugging. It might be useful to augment the readName KryoException to mention that the user might be passing in the same buffer. |
It would be pretty easy to create a version that is just as fast but can accept the same byte[] buffer in multiple inputs. I think this is a much better solution than users copying bytes before passing into Input. https://gist.github.com/devinrsmith/627573047e4e2884836f My version isn't as fast b/c it does an extra copy, but that could be gotten rid of if necessary. |
We would need to write an extra byte per string to avoid the copy. On Fri, Nov 14, 2014 at 6:23 PM, Devin Smith notifications@github.com
|
You can avoid the extra copy w/o binary incompatibility by building up a char[] instead and calling Strings private constructor. |
"building up a char[]" is a copy. On Fri, Nov 14, 2014 at 6:55 PM, Devin Smith notifications@github.com
|
You are already doing that via the public String constructor:
|
I'm suggesting building the char[] yourself and calling
|
Using the public API, String is going to do a copy no matter what as it's
On Fri, Nov 14, 2014 at 7:03 PM, Devin Smith notifications@github.com
|
@NathanSweet fixed in 5.0? |
Yep. |
After lots of debugging and testing out different theories, I found a multithreaded bug that causes non-deterministic results in Input.readAscii.
Specifically, Input.readAscii modifies the user's passed in buffer. If the user passes in the same buffer pointer to multiple Inputs, then readAscii instances may read past the proper end.
While it might seem rare that somebody is deserializing the same exact buffer multiple times, it definitely comes into play when running DBs in memory.
It looks like this is the only place in Input that modifies the buffer.
The text was updated successfully, but these errors were encountered: