Skip to content

Commit 422494e

Browse files
Copilotbrianrob
andauthored
Fix incorrect field offsets when parsing ETW events with fixed-count array fields (#2427)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: brianrob <6210322+brianrob@users.noreply.github.com>
1 parent 3162599 commit 422494e

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/TraceEvent/RegisteredTraceEventParser.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,17 @@ private DynamicTraceEventData.PayloadFetchClassInfo ParseFields(int startField,
10461046
else
10471047
{
10481048
Debug.WriteLine(" Field is an array of size " + ((fixedCount != 0) ? fixedCount.ToString() : "VARIABLE") + " of type " + ((propertyFetch.Type ?? typeof(void))) + " at offset " + arrayFieldOffset.ToString("x"));
1049-
propertyFetch = DynamicTraceEventData.PayloadFetch.ArrayPayloadFetch(arrayFieldOffset, propertyFetch, arraySize, fixedCount, projectCharArrayAsString:false);
1049+
if (fixedCount != 0)
1050+
{
1051+
// Use FixedCountArrayPayloadFetch so that Size is set to the total byte size
1052+
// (fixedCount * element.Size) rather than just the element count, ensuring that
1053+
// subsequent field offsets are computed correctly.
1054+
propertyFetch = DynamicTraceEventData.PayloadFetch.FixedCountArrayPayloadFetch(arrayFieldOffset, propertyFetch, fixedCount, projectCharArrayAsString:false);
1055+
}
1056+
else
1057+
{
1058+
propertyFetch = DynamicTraceEventData.PayloadFetch.ArrayPayloadFetch(arrayFieldOffset, propertyFetch, arraySize, 0, projectCharArrayAsString:false);
1059+
}
10501060
}
10511061

10521062
fieldOffset = ushort.MaxValue; // Indicate that the next offset must be computed at run time.

0 commit comments

Comments
 (0)