-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enforce 64KB event payload size limit on EventPipe (#50600)
* allow >100KB events to be written * prevent events > 64KB from being written * code review feedback * increment seq num * fix build * fix build on clang * fix mono build
- Loading branch information
Showing
4 changed files
with
130 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Diagnostics.Tracing; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using System.Collections.Generic; | ||
using Microsoft.Diagnostics.Tools.RuntimeClient; | ||
using Microsoft.Diagnostics.Tracing; | ||
using Tracing.Tests.Common; | ||
using Microsoft.Diagnostics.Tracing.Parsers.Clr; | ||
|
||
namespace Tracing.Tests.BigEventsValidation | ||
{ | ||
|
||
public sealed class BigEventSource : EventSource | ||
{ | ||
private static string bigString = new String('a', 100 * 1024); | ||
private static string smallString = new String('a', 10); | ||
|
||
private BigEventSource() | ||
{ | ||
} | ||
|
||
public static BigEventSource Log = new BigEventSource(); | ||
|
||
public void BigEvent() | ||
{ | ||
WriteEvent(1, bigString); | ||
} | ||
|
||
public void SmallEvent() | ||
{ | ||
WriteEvent(2, smallString); | ||
} | ||
} | ||
|
||
|
||
public class BigEventsValidation | ||
{ | ||
public static int Main(string[] args) | ||
{ | ||
// This test tries to send a big event (>100KB) and checks that the app does not crash | ||
// See https://github.com/dotnet/runtime/issues/50515 for the regression issue | ||
var providers = new List<Provider>() | ||
{ | ||
new Provider("BigEventSource") | ||
}; | ||
|
||
var configuration = new SessionConfiguration(circularBufferSizeMB: 1024, format: EventPipeSerializationFormat.NetTrace, providers: providers); | ||
return IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, configuration, _Verify); | ||
} | ||
|
||
private static Dictionary<string, ExpectedEventCount> _expectedEventCounts = new Dictionary<string, ExpectedEventCount>() | ||
{ | ||
{ "BigEventSource", -1 } | ||
}; | ||
|
||
private static Action _eventGeneratingAction = () => | ||
{ | ||
// Write 10 big events | ||
for (int i = 0; i < 10; i++) | ||
{ | ||
BigEventSource.Log.BigEvent(); | ||
} | ||
// Write 10 small events | ||
for (int i = 0; i < 10; i++) | ||
{ | ||
BigEventSource.Log.SmallEvent(); | ||
} | ||
}; | ||
|
||
private static Func<EventPipeEventSource, Func<int>> _Verify = (source) => | ||
{ | ||
bool hasSmallEvent = false; | ||
source.Dynamic.All += (TraceEvent data) => | ||
{ | ||
if (data.EventName == "SmallEvent") | ||
{ | ||
hasSmallEvent = true; | ||
} | ||
}; | ||
return () => hasSmallEvent ? 100 : -1; | ||
}; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier> | ||
<OutputType>exe</OutputType> | ||
<CLRTestKind>BuildAndRun</CLRTestKind> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<CLRTestPriority>0</CLRTestPriority> | ||
<JitOptimizationSensitive>true</JitOptimizationSensitive> | ||
<UnloadabilityIncompatible>true</UnloadabilityIncompatible> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
<ProjectReference Include="../common/common.csproj" /> | ||
</ItemGroup> | ||
</Project> |