-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
EmptyByteBuf referencing Cleaner instances that change #9750
Comments
PR with fix. |
The solution proposed of recomputed So, I'm now investigating if EmptyByteBuf could be a runtime initialised class. Another option would to see if the EmptyByteBuf is really needed/used by Quarkus and see if the path to method that makes this class to be stored in the heap can be cut off. |
Yet another option would be to patch the Netty code to initialize More options would include exploring whether the |
…o#9750 * Recompute the field from a unused direct byte buffer. * Also, set empty byte buffer memory address to 0.
…o#9750 * Recompute the field from a unused direct byte buffer. * Also, set empty byte buffer memory address to 0.
With the current state of things, it'd appear that runtime initialization does not work (see here). No clues after adding -H:+TraceClassInitialization (see here). I've hooked a debugger to find out why the
ByteBufAllocator links to it which brings it to build time. It's also interesting to see how the empty byte memory address is calculated at build time. Seems to me that should be disabled (recompute field to 0), or done at runtime (see here). The original idea of reset EMPTY_BYTE_BUFFER to null might still work, but it also needs more help to avoid NPE: the memory address should be set to 0, and then substitute any methods that use the empty byte buffer for a new one. I've also try to use alias to avoid reusing the one that has been used when calculating the memory address but that didn't work. |
New PR with a better fix. |
Trying Andrew's debug info stuff I encountered this:
Adding debug info might be triggering extra GC cycles that results in Cleaner references changing while the heap is being written.
There might be multiple ways of fixing this, but one that have seemed to work for me is to mark EmptyByteBuf.EMPTY_BYTE_BUFFER as a recomputed field with kind Reset.
Other potential solutions (not tried) might be to make EmptyByteBuf a runtime initialized class?
I'll send a PR in a bit.
The text was updated successfully, but these errors were encountered: