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

GC: writeJsonSummary writes file with interleaved null characters #4644

Closed
N-o-Z opened this issue Nov 23, 2022 · 2 comments · Fixed by #4808
Closed

GC: writeJsonSummary writes file with interleaved null characters #4644

N-o-Z opened this issue Nov 23, 2022 · 2 comments · Fixed by #4808
Assignees
Labels
bug Something isn't working GC+ team/ecosystem Team Ecosystem

Comments

@N-o-Z
Copy link
Member

N-o-Z commented Nov 23, 2022

The function uses stream.writeChars on a JObject which results in a an invalid string, which causes an exception when trying to read into json object afterwards

[�, {, �, ", �, r, �, u, �, n, �, _, �, i, �, d, �, ", �, :, �, ", �, 1, �, 4, �, 1, �, 9, �, f, �, c, �, e, �, a, �, -, �, a, �, 4, �, 4, �, 1, �, -, �, 4, �, 9, �, 7, �, b, �, -, �, b, �, 3, �, 0, �, 1, �, -, �, 2, �, 4, �, 6, �, c, �, 7, �, f, �, 3, �, 6, �, 0, �, 1, �, b, �, a, �, ", �, ,, �, ", +178 more]

Suggested solution to use writeBytes instead

@N-o-Z N-o-Z added team/ecosystem Team Ecosystem GC+ labels Nov 23, 2022
@N-o-Z
Copy link
Member Author

N-o-Z commented Nov 23, 2022

@Jonathan-Rosenberg FYI

@talSofer talSofer added the bug Something isn't working label Nov 30, 2022
arielshaqed added a commit that referenced this issue Dec 13, 2022
Tested by adding a unit test for writeJsonSummary.

Fixes #4644.
@arielshaqed
Copy link
Contributor

Analysis

writeJsonSummary uses DataOutputStream.writeChars, which writes each char of the String as if using DataOutputStream.writeChar, which literally says it does a bad UTF-16 impression:

Writes a char to the underlying output stream as a 2-byte value, high byte first. If no exception is thrown, the counter written is incremented by 2.

We shouldn't use that function 🤷🏽 .

arielshaqed added a commit that referenced this issue Dec 14, 2022
* Write GC summary file using UTF-8

Tested by adding a unit test for writeJsonSummary.

Fixes #4644.

* [CR] Always delete temporary directory

* Remove useless debug print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working GC+ team/ecosystem Team Ecosystem
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants