Review Request for JMC-6621 - Handle event size 0

Marcus Hirt marcus.hirt at datadoghq.com
Thu Oct 31 14:46:33 UTC 2019


Looks good to me. We may also want to support a mode where we allow
the parser to return with whatever it had read up until that point,
like we do with chunks. That can be done in a separate issue though.

Kind regards,
Marcus

On Thu, Oct 31, 2019 at 3:44 PM Henrik Dafgård <hdafgard at gmail.com> wrote:
>
> Hi Erik,
>
> Using "jfr print" on a recording with a zero event size works as expected,
> but running "jfr summary" on it doesn't produce a result. It seems to also
> be stuck in an infinite loop.
>
>
> Cheers,
> Henrik Dafgård
>
>
> On Thu, 31 Oct 2019 at 15:29, Erik Gahlin <erik.gahlin at oracle.com> wrote:
>
> > Looks good.
> >
> > The JDK parser checks for a zero size, so the JMC parser should do the
> > same,
> >
> > Erik
> >
> > > On 31 Oct 2019, at 15:05, Henrik Dafgård <hdafgard at gmail.com> wrote:
> > >
> > > Hi all,
> > >
> > > Should JMC attempt to parse a recording with an event size of 0 (this
> > > should not be possible) it will currently enter an infinite loop. The
> > patch
> > > outlined below simply adds a check for size 0 and then throws a
> > > CouldNotLoadRecordingException if that is the case.
> > >
> > > diff -r b153474a15a6
> > >
> > core/org.openjdk.jmc.flightrecorder/src/main/java/org/openjdk/jmc/flightrecorder/internal/parser/v1/ChunkLoaderV1.java
> > > ---
> > >
> > a/core/org.openjdk.jmc.flightrecorder/src/main/java/org/openjdk/jmc/flightrecorder/internal/parser/v1/ChunkLoaderV1.java
> > > Fri Oct 25 15:48:20 2019 +0200
> > > +++
> > >
> > b/core/org.openjdk.jmc.flightrecorder/src/main/java/org/openjdk/jmc/flightrecorder/internal/parser/v1/ChunkLoaderV1.java
> > > Thu Oct 31 15:00:27 2019 +0100
> > > @@ -84,6 +84,9 @@
> > >  input.seek(index);
> > >  int size = input.readInt();
> > >  long type = input.readLong();
> > > + if (size == 0) {
> > > + throw new CouldNotLoadRecordingException("Found event with invalid size
> > > (0)");
> > > + }
> > >  if (type != CONSTANT_POOL_EVENT_TYPE && type !=
> > > ChunkMetadata.METADATA_EVENT_TYPE) {
> > >  manager.readEvent(type, input);
> > >  }
> > >
> > >
> > > Cheers,
> > > Henrik Dafgård
> >
> >


More information about the jmc-dev mailing list