Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8309550

jdk.jfr.internal.Utils::formatDataAmount method should gracefully handle amounts equal to Long.MIN_VALUE

    XMLWordPrintable

Details

    • jfr
    • b26

    Backports

      Description

        The method formatDataAmount(String formatter, long amount) in jdk.jfr.internal.Utils throws a StringIndexOutOfBoundsException when amount is equal to Long.MIN_VALUE.

        A comment in the method itself warns that Long.MIN_VALUE isn't properly handled since its absolute value is negative, but no explicit attempt to reject such value is ever made (e.g. throw IllegalArgumentException): instead this will cause the rest of the code to fail with the exception above.

        It is important that Long.MIN_VALUE amounts be handled correctly by this method because it is used by jdk.jfr.internal.tool.PrettyWriter which in turn in called by RecordedEvent.toString and the "jfr print" command, which therefore fail with the above exception when encountering recordings that contain events with a field typed as BYTES and a value of Long.MIN_VALUE.

        This is not a theoretical risk either, as for example every instance of jdk.YoungGenerationConfiguration captured when using ShenandoahGC (and I suspect any other non-generational GC) appear to have a maxSize field with a value of Long.MIN_VALUE.

        Attachments

          Issue Links

            Activity

              People

                fthevenet Frederic Thevenet
                fthevenet Frederic Thevenet
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: