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

Profile: fix heap snapshot is valid char check #53984

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion stdlib/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
version = "1.11.0"

[[deps.Profile]]
deps = ["Unicode"]
uuid = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"
version = "1.11.0"

Expand Down
6 changes: 0 additions & 6 deletions stdlib/Profile/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ name = "Profile"
uuid = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"
version = "1.11.0"

[deps]
Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[compat]
Unicode = "1.11.0"

[extras]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Expand Down
4 changes: 1 addition & 3 deletions stdlib/Profile/src/heapsnapshot_reassemble.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

module HeapSnapshot

using Unicode

"""
assemble_snapshot(filepath::AbstractString, out_file::AbstractString)

Expand Down Expand Up @@ -236,7 +234,7 @@ function print_str_escape_json(stream::IO, s::AbstractString)
print(stream, "\\t")
elseif '\x00' <= c <= '\x1f'
print(stream, "\\u", lpad(string(UInt16(c), base=16), 4, '0'))
elseif !Unicode.isassigned(c)
elseif !isvalid(c)
# we have to do this because vscode's viewer doesn't like the replace character
print(stream, "[invalid unicode character]")
Copy link
Member

Choose a reason for hiding this comment

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

So writing out any of these would not work: \\uFFFD or \uFFFD or ? I wonder if a simple ? might be better than this long text to replace each invalid byte

Copy link
Member Author

Choose a reason for hiding this comment

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

I can't say I characterized it that well. Just that this appears to work. It could be too strict. A ? sounds good

else
Expand Down