KEMBAR78
Do not write T_PACKAGE header, if there are no packages. by krk · Pull Request #1075 · async-profiler/async-profiler · GitHub
Skip to content

Conversation

@krk
Copy link
Contributor

@krk krk commented Dec 6, 2024

This may happen while profiling non-java programs.

Description

jfr print broken while profiling non-jvm apps:

jfr print: unexpected internal error, Pool jdk.types.Package must contain at least one element
java.lang.InternalError: Pool jdk.types.Package must contain at least one element
        at jdk.jfr/jdk.jfr.internal.consumer.ChunkParser.fillConstantPools(ChunkParser.java:357)
        at jdk.jfr/jdk.jfr.internal.consumer.ChunkParser.<init>(ChunkParser.java:141)
        at jdk.jfr/jdk.jfr.internal.consumer.ChunkParser.<init>(ChunkParser.java:109)
        at jdk.jfr/jdk.jfr.internal.consumer.ChunkParser.<init>(ChunkParser.java:105)
        at jdk.jfr/jdk.jfr.consumer.RecordingFile.createChunkParser(RecordingFile.java:318)
        at jdk.jfr/jdk.jfr.consumer.RecordingFile.findNext(RecordingFile.java:294)
        at jdk.jfr/jdk.jfr.consumer.RecordingFile.<init>(RecordingFile.java:89)
        at jdk.jfr/jdk.jfr.internal.tool.EventPrintWriter.print(EventPrintWriter.java:74)
        at jdk.jfr/jdk.jfr.internal.tool.Print.execute(Print.java:165)
        at jdk.jfr/jdk.jfr.internal.tool.Main.main(Main.java:92)

Do not write the T_PACKAGE prelude in the constant pool, if there are no packages.

How has this been tested?

LD_PRELOAD async-profiler into a native app, jfr print the resulting jfr file.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

This may happen while profiling non-java programs.
writeLogLevels(buf);

// Patch pool count.
buf->put8(poolCountOffset, poolCount);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not that trivial.
Buffer can be flushed while dumping other constant pools.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the problem is relevant to other dictionaries, too - for example, when a recording contains no samples.
An alternative workaround that I thought of is to populate dictionary with a dummy element if it is empty.

@krk
Copy link
Contributor Author

krk commented Dec 6, 2024

Closing for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants