Field maxSize of event jdk.YoungGenerationConfiguration can be set to Long.MIN_VALUE

Frederic Thevenet fthevene at redhat.com
Tue Jun 6 19:56:25 UTC 2023


Hi,

I recently reported on an issue where invoking the command "jfr print" 
on a recording that contain events where one of the field in is an 
amount in bytes whose value is Long.MIN_VALUE (or invoking "toString()" 
on such an event), you'd the following error:
jfr print: unexpected internal error, Index -1 out of bounds for length 6

Now, I believe the root cause and fix to the issue to be pretty trivial 
and I submitted a PR for that, but I am trying to understand if the 
event that revealed the bug is really supposed to report such a value, 
or if there's another problem at play here.

The event type in question is "jdk.YoungGenerationConfiguration" whose 
"maxSize" field is always equal to Long.MIN_VALUE when the GC in use is 
ShenandoahGC or ZGC.
Now, I'm guessing that Shenandoah and ZGC not being generational, this 
particular configuration item is probably mostly ignored/useless, in 
which case, I feel it isn't fully unexpected that if present 
nonetheless, such events would be populated with default values which, 
from a cursory glance at gcConfiguration.hpp[2] looks like maxSize is 
set to the maximum value of uintx (which when cast as a java long would 
be Long.MIN_VALUE if I'm not mistaking):

class GCYoungGenerationConfiguration {
  public:
   bool has_max_size_default_value() const;
   uintx max_size() const;
   uintx min_size() const;
   intx new_ratio() const;
};

I'm not 100% sure that my understanding of the whole thing is correct 
here, so please do not hesitate to correct me if it isn't.

Furthermore, I'm unsure whether or not the fact that maxSize is 
effectively set to Long.MIN_VALUE is necessarily an issue here (as long 
as the code that handles the formatting is fixed, of course): maybe the 
value carries a specific meaning I'm unaware of.

I would really appreciate it if someone here is a position to shed some 
light on the matter for me.

Thanks!
Frederic

[1] https://bugs.openjdk.org/browse/JDK-8309550
[2] 
https://github.com/openjdk/jdk/blob/4a75fd462c002a209201d8bfc8d6c9eb286a7444/src/hotspot/share/gc/shared/gcConfiguration.hpp#L71

-- 
Frederic Thevenet
Senior Software Engineer - OpenJDK
Red Hat France <https://www.redhat.com>
BAF5 C2D2 0BE0 1715 5EE1 0815 2065 AD47 B326 EB92



More information about the hotspot-jfr-dev mailing list