-
-
Notifications
You must be signed in to change notification settings - Fork 647
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
JVM crash: org.lwjgl.system.MemoryUtil reaches after the end of the object #491
Comments
Originally found by running Minecraft with fastdebug binaries: |
Thank you @shipilev, Tracked it down to JDK-8208362. I was actually aware of the old behavior and found it unreasonable, that's why the custom slice/duplicate implementations in LWJGL do the same thing as JDK 12, i.e. attach the source buffer's attachment. But I never made the connection that it's an implementation detail that, if changed, would bite us in the offset detection code. I've implemented Btw, field offsets are detected using Unsafe so that users can drop LWJGL in modular applications without having to mess with JVM arguments to allow reflective access to |
Interesting. Does this mean JDK-8208362 should be backported to 11u and 8u to make LWJGL use it there as well? |
LWJGL does not require JDK-8208362, it works fine on either 8-11 or 12+ after the above fix. If backported, LWJGL users migrating to the newer JDK would also need to update to latest LWJGL. The bug exists since 3.2.1, which is the version Minecraft uses afaik. |
Pity. So if JDK-8208362 enters newer 11u or 8u, then current Minecraft running with those new 11u or 8u would crash until it is upgraded to LWJGL 3.2.3+. That means the less risky way would be waiting for LWJGL-dependent projects to make the update, and then consider backporting the JDK change that resolves the memory leak (for everyone, not only LWJGL users). |
I would generally be in favor of going ahead with the backport, the JDK has top priority and LWJGL can handle the support burden. But in this case I would also argue that the JDK-8208362 fix is nowhere near critical. The leak can be demonstrated trivially, but real-life nio code doesn't create such long attachment chains. |
Happens in current Git tip with fastdebug OpenJDK binaries. I use my own builds below, but this can be reproduced with self-built OpenJDK binaries too.
The top of the stack is:
So I think
org.lwjgl.system.MemoryUtil.getParentOffset
reaches to something after the end of the object. This is incorrect and caught by JVM assert. It could have crashed the JVM without the assert, especially in release builds.The text was updated successfully, but these errors were encountered: