Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read CPool Constant Index as uint64 #38

Merged

Conversation

sivachandran
Copy link
Contributor

As per https://www.morling.dev/blog/jdk-flight-recorder-file-format/ and https://www.morling.dev/images/jfr_file_format.svg the Constant Index is a 64bit var-int. But the implementation uses 32bit var-int parser. The existing implementation fails with the included jfr which was generated from Java 17.

Now the implementation is changed to read the constant index as 64bit var-int

image

@korniltsev korniltsev merged commit 059831e into grafana:main Sep 3, 2024
2 checks passed
@korniltsev
Copy link
Collaborator

Thank you

@sivachandran sivachandran deleted the read-cpool-constant-index-as-u64 branch September 3, 2024 10:41
@sivachandran
Copy link
Contributor Author

@korniltsev Can you create a tag for the latest version?

@korniltsev
Copy link
Collaborator

@sivachandran Sorry for asking after merging, but I have a followup question?

What constant exactly had the issue? And how does it work now?

Don't we need to update IDMap implementation and all the XXXRef types and XXXList.IDMap field as they rely on id being uint32.

For example this code truncates id from the new u64 to u32 back?

id := SymbolRef(v64_)

@sivachandran
Copy link
Contributor Author

sivachandran commented Sep 3, 2024

I'm getting the below error without the change

panic: jfr parser ParseEvent error: error reading CP: error reading class{name: jdk.types.DeoptimizationReason, id: 154, fields: [{Name:reason Type:212 ConstantPool:false Array:false}]} int overflow @ 439211

goroutine 1 [running]:
main.main()
        /home/sivachandran/Workspace/personal/jfr-parser/cmd/jfrparser/main.go:62 +0x1a5

It is failing to parse jdk.types.DeoptimizationReason from ConstantPool. The type is unknown to the implementation. So it tries to parse using SkipConstantPool struct. While parsing SkipConstantPool it fails parsing the constant index.

Don't we need to update IDMap implementation and all the XXXRef types and XXXList.IDMap field as they rely on id being uint32.

Yes, we should. I failed to realise. I will raise a separate PR for those changes.

@sivachandran
Copy link
Contributor Author

The test didn't fail as the parsed type is not really used anywhere.

@korniltsev
Copy link
Collaborator

Great, thank you so much.

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