Fix incorrect field offsets when parsing ETW events with fixed-count array fields#2427
Draft
Copilot wants to merge 2 commits into
Draft
Fix incorrect field offsets when parsing ETW events with fixed-count array fields#2427Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
When processing ETW events with fixed-count array fields (e.g. from TraceLoggingUInt32FixedArray / TraceLoggingFloat32FixedArray), the PayloadFetch.Size was being set to the element count instead of the total byte size. This caused OffsetOfNextField to advance by only `fixedCount` bytes instead of `fixedCount * elementSize` bytes, corrupting the offsets of all subsequent fields. Fix: use FixedCountArrayPayloadFetch (which correctly computes size = elementCount * element.Size) instead of ArrayPayloadFetch when fixedCount != 0, matching the pattern already used in EventPipeMetadata.cs. Co-authored-by: brianrob <6210322+brianrob@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix parsing issues for fixed array data arguments
Fix incorrect field offsets when parsing ETW events with fixed-count array fields
May 26, 2026
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.
ETW events using
TraceLoggingUInt32FixedArray,TraceLoggingFloat32FixedArray, or any other fixed-count TraceLogging array type produced corrupted values for all fields following the first fixed array field. WPA parsed these correctly; TraceEvent did not.Root cause
In
RegisteredTraceEventParser.TdhEventParser.ParseFields, the fixed-count array path setarraySize = fixedCount(element count, e.g.3) and passed that as thesizeargument toArrayPayloadFetch. This stored the element count as the byte size onPayloadFetch.Size. SinceOffsetOfNextFieldusesPayloadFetch.Sizedirectly to advance past the field, every subsequent field was off byfixedCount * elementSize - fixedCountbytes (e.g., off by 9 bytes for a 3-elementfloat32array).Fix
Replace the
ArrayPayloadFetchcall withFixedCountArrayPayloadFetchwhenfixedCount != 0. This existing helper correctly computessize = elementCount * element.Sizebefore forwarding toArrayPayloadFetch— the same pattern already used inEventPipeMetadata.cs.