Fix dotnet-pgo dump crash when CallWeights are present#125936
Merged
eiriktsarpalis merged 1 commit intodotnet:mainfrom Mar 23, 2026
Merged
Fix dotnet-pgo dump crash when CallWeights are present#125936eiriktsarpalis merged 1 commit intodotnet:mainfrom
eiriktsarpalis merged 1 commit intodotnet:mainfrom
Conversation
The JSON serialization of CallWeights in the dump command writes named properties (Method, Weight) directly inside a JSON array without wrapping each entry in an object, causing InvalidOperationException. Add WriteStartObject/WriteEndObject around each CallWeights entry. Fixes dotnet#125935
Contributor
|
Tagging subscribers to this area: @agocke |
14 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes dotnet-pgo dump JSON generation for .mibc files that include CallWeights by ensuring each array element is a proper JSON object, preventing Utf8JsonWriter from throwing when writing named properties inside an array.
Changes:
- Wrap each
CallWeightsentry withWriteStartObject()/WriteEndObject()during dump JSON serialization.
3 tasks
hoyosjs
approved these changes
Mar 23, 2026
eiriktsarpalis
approved these changes
Mar 23, 2026
Member
|
/ba-g test failure is unrelated |
eiriktsarpalis
pushed a commit
that referenced
this pull request
Mar 23, 2026
## Summary
Fix `InvalidOperationException` in `dotnet-pgo dump` when the .mibc file
contains CallWeights data.
## Problem
The JSON serialization writes named properties (`Method`, `Weight`)
directly inside a JSON array without wrapping each entry in a JSON
object:
```csharp
jsonWriter.WriteStartArray("CallWeights");
foreach (var callWeight in data.CallWeights)
{
jsonWriter.WriteString("Method", ...); // crash: property inside array
jsonWriter.WriteNumber("Weight", ...);
}
```
## Fix
Add `WriteStartObject()` / `WriteEndObject()` around each array entry.
Fixes #125935
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix
InvalidOperationExceptionindotnet-pgo dumpwhen the .mibc file contains CallWeights data.Problem
The JSON serialization writes named properties (
Method,Weight) directly inside a JSON array without wrapping each entry in a JSON object:Fix
Add
WriteStartObject()/WriteEndObject()around each array entry.Fixes #125935