From a3de5c59ad824d51d3a7890de129fd05586e715c Mon Sep 17 00:00:00 2001 From: John Salem Date: Wed, 15 Jan 2020 17:26:56 -0800 Subject: [PATCH 1/3] Update TraceEvent package version --- src/coreclr/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/dependencies.props b/src/coreclr/dependencies.props index 6336b791dc580..06a25f2a47092 100644 --- a/src/coreclr/dependencies.props +++ b/src/coreclr/dependencies.props @@ -8,7 +8,7 @@ 1.0.0-beta-build0015 - 2.0.43 + 2.0.49 1.0.4-preview6.19326.1 2.2.0 From 71f0cc2fa6ed57fafc65407125c43da3f3d4f67a Mon Sep 17 00:00:00 2001 From: John Salem Date: Thu, 16 Jan 2020 17:25:16 -0800 Subject: [PATCH 2/3] Workaround for deadlock in EventPipe * Remove this change once the fix has be made --- .../src/tracing/eventpipe/common/IpcTraceTest.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/coreclr/tests/src/tracing/eventpipe/common/IpcTraceTest.cs b/src/coreclr/tests/src/tracing/eventpipe/common/IpcTraceTest.cs index 54ec02ebdab6a..04d2b51341b80 100644 --- a/src/coreclr/tests/src/tracing/eventpipe/common/IpcTraceTest.cs +++ b/src/coreclr/tests/src/tracing/eventpipe/common/IpcTraceTest.cs @@ -9,6 +9,7 @@ using System.Threading; using System.Threading.Tasks; using System.Collections.Generic; +using System.Collections.Concurrent; using Microsoft.Diagnostics.Tracing; using Microsoft.Diagnostics.Tools.RuntimeClient; using System.Runtime.InteropServices; @@ -173,6 +174,16 @@ private int Fail(string message = "") private int Validate() { + // FIXME: This is a bandaid fix for a deadlock in EventPipeEventSource caused by + // the lazy caching in the Regex library. The caching creates a ConcurrentDictionary + // and because it is the first one in the process, it creates and EventSource which + // results in a deadlock over a lock in EventPipe. This line should be removed once the + // underlying issue is fixed. + // + // see: https://github.com/dotnet/runtime/pull/1794 for details on the issue + // + var emptyConcurrentDictionary = new ConcurrentDictionary(); + var isClean = EnsureCleanEnvironment(); if (!isClean) return -1; From 47daa0796e1463caf894ff0327bcf1b601933d6d Mon Sep 17 00:00:00 2001 From: John Salem Date: Fri, 17 Jan 2020 11:20:15 -0800 Subject: [PATCH 3/3] Force the event source to be created --- .../tests/src/tracing/eventpipe/common/IpcTraceTest.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/coreclr/tests/src/tracing/eventpipe/common/IpcTraceTest.cs b/src/coreclr/tests/src/tracing/eventpipe/common/IpcTraceTest.cs index 04d2b51341b80..c10968f519683 100644 --- a/src/coreclr/tests/src/tracing/eventpipe/common/IpcTraceTest.cs +++ b/src/coreclr/tests/src/tracing/eventpipe/common/IpcTraceTest.cs @@ -176,13 +176,15 @@ private int Validate() { // FIXME: This is a bandaid fix for a deadlock in EventPipeEventSource caused by // the lazy caching in the Regex library. The caching creates a ConcurrentDictionary - // and because it is the first one in the process, it creates and EventSource which - // results in a deadlock over a lock in EventPipe. This line should be removed once the - // underlying issue is fixed. + // and because it is the first one in the process, it creates an EventSource which + // results in a deadlock over a lock in EventPipe. These lines should be removed once the + // underlying issue is fixed by forcing these events to try to be written _before_ we shutdown. // // see: https://github.com/dotnet/runtime/pull/1794 for details on the issue // var emptyConcurrentDictionary = new ConcurrentDictionary(); + emptyConcurrentDictionary["foo"] = "bar"; + var __count = emptyConcurrentDictionary.Count; var isClean = EnsureCleanEnvironment(); if (!isClean)