summaryrefslogtreecommitdiff
path: root/src/System.Private.CoreLib
diff options
context:
space:
mode:
authorNoah Falk <noahfalk@users.noreply.github.com>2019-10-30 17:09:33 -0700
committerDan Moseley <danmose@microsoft.com>2019-10-30 17:09:33 -0700
commita0a1e56cc5fb53b47d5ad43ff100e4de28700b38 (patch)
treeca1916a1e72ec6a42a264a7548aa09374b37d2fc /src/System.Private.CoreLib
parent934ef618a9e3abf968e5783b8efa28e9c1caf295 (diff)
downloadcoreclr-a0a1e56cc5fb53b47d5ad43ff100e4de28700b38.tar.gz
coreclr-a0a1e56cc5fb53b47d5ad43ff100e4de28700b38.tar.bz2
coreclr-a0a1e56cc5fb53b47d5ad43ff100e4de28700b38.zip
Support large EventSource filter args (#27522)
1. Fix NullReferenceException. When the filter args exceeded the hard-coded size limit GetDataFromController would return data = null. The code previously asserted that data was not null and triggered NRE when it was. The fix correctly null checks the value instead of asserting and uses an empty args dictionary in this case, the same as if filter args had been empty to begin with. 2. ETW has always limited filter args to 1024 bytes but EventPipe has no such restriction. When using DiagnosticSourceEventSource it can be useful to specify a larger filter arg blob. I can't do anything about ETW's restriction but there is no need for the runtime to force EventPipe to be equally limited. The larger size also reduces the chance that we need to hit the fallback path above causing filter args to be ignored.
Diffstat (limited to 'src/System.Private.CoreLib')
-rw-r--r--src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventProvider.cs28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventProvider.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventProvider.cs
index 7322209ee8..abc56be55f 100644
--- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventProvider.cs
+++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventProvider.cs
@@ -322,19 +322,22 @@ namespace System.Diagnostics.Tracing
GetDataFromController(etwSessionId, filterData, out command, out data, out keyIndex))
{
args = new Dictionary<string, string?>(4);
- Debug.Assert(data != null);
- while (keyIndex < data.Length)
+ // data can be null if the filterArgs had a very large size which failed our sanity check
+ if (data != null)
{
- int keyEnd = FindNull(data, keyIndex);
- int valueIdx = keyEnd + 1;
- int valueEnd = FindNull(data, valueIdx);
- if (valueEnd < data.Length)
+ while (keyIndex < data.Length)
{
- string key = System.Text.Encoding.UTF8.GetString(data, keyIndex, keyEnd - keyIndex);
- string value = System.Text.Encoding.UTF8.GetString(data, valueIdx, valueEnd - valueIdx);
- args[key] = value;
+ int keyEnd = FindNull(data, keyIndex);
+ int valueIdx = keyEnd + 1;
+ int valueEnd = FindNull(data, valueIdx);
+ if (valueEnd < data.Length)
+ {
+ string key = System.Text.Encoding.UTF8.GetString(data, keyIndex, keyEnd - keyIndex);
+ string value = System.Text.Encoding.UTF8.GetString(data, valueIdx, valueEnd - valueIdx);
+ args[key] = value;
+ }
+ keyIndex = valueEnd + 1;
}
- keyIndex = valueEnd + 1;
}
}
@@ -635,7 +638,10 @@ namespace System.Diagnostics.Tracing
}
else
{
- if (filterData->Ptr != 0 && 0 < filterData->Size && filterData->Size <= 1024)
+ // ETW limited filter data to 1024 bytes but EventPipe doesn't. DiagnosticSourceEventSource
+ // can legitimately use large filter data buffers to encode a large set of events and properties
+ // that should be gathered so I am bumping the limit from 1K -> 100K.
+ if (filterData->Ptr != 0 && 0 < filterData->Size && filterData->Size <= 100*1024)
{
data = new byte[filterData->Size];
Marshal.Copy((IntPtr)filterData->Ptr, data, 0, data.Length);