Question regarding JVM crashes in GC

Michael Rasmussen michael.rasmussen at zeroturnaround.com
Thu Apr 6 11:42:34 UTC 2017


On 6 April 2017 at 12:58, Stefan Johansson <stefan.johansson at oracle.com> wrote:
> Interesting, the GC (or rather reference processing) actually do have some
> assumptions when it comes to the fields in reference objects. We expect the
> referent, discovered and next fields to be at certain offsets. You mentioned
> earlier that such assumptions might be problematic, are you doing any kind
> of instrumentation that could change those offsets?

Generally, we are doing instrumentation that add fields to classes, so
can change those offsets, but it doesn't seem to affect the Reference
classes.
I ran some tests with and without JRebel, printing out the results of
unsafe::objectFieldOffset and unsafe::staticFieldOffset for all
declared fields on PhantomReference, WeakReference, SoftReference and
Reference. The offsets were identical. So assuming those unsafe
methods return the equivalent of what's used internally, then we don't
modify the offset.

We are using a JVMTI agent for instrumenting the early classes
(classes loaded before premain is called), I'm currently trying to
investigate if this is causing some side effects, since when doing the
equivalent using --patch-module, I cannot reproduce it with a simple
main() { System.gc(); } test class.

/Michael


More information about the hotspot-dev mailing list