-
Notifications
You must be signed in to change notification settings - Fork 408
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
Safer UnsafeBuffer.toString() and UnsafeBuffer.hashcode() #106
Comments
It should be the case that you don't call anything, except possibly wrapping another buffer, after an unmap. |
So for context in this case I was logging when a buffer was being closed in order to discover which buffer wasn't being closed. I wouldn't expect to be able to do anything else to a buffer, but the behaviour of segfaulting the JVM on I called toString() was quite surprising. |
BTW there is no toString() method on UnsafeBuffer other than the one inherited from Object. There is an equals and hashCode. What was the issue with toString() you are seeing? |
Yeah, sorry I should have explained it better. UnsafeBuffer inherits the toString() method from Object, which then invokes hashcode() on itself, thus calling UnsafeBuffer.hashcode(). the hashcode() causes the segfault. |
That makes more sense. We should provide one that does a reasonable thing so debuggers don't cause a crash in that case. |
If an UnsafeBuffer is wrapping an underlying mappedbytebuffer and it gets unmapped/closed then operations like toString() and hashcode() cause a segfault, because they rely on the values of the mappedbytebuffer. I'm wondering if there's not a safer way of doing things? Or perhaps at least documenting: don't call toString() or hashcode() after you've been unmapped.
The text was updated successfully, but these errors were encountered: