Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventPipe deadlock in provider creation/session termination #36108

Closed
davmason opened this issue May 8, 2020 · 2 comments
Closed

EventPipe deadlock in provider creation/session termination #36108

davmason opened this issue May 8, 2020 · 2 comments

Comments

@davmason
Copy link
Member

davmason commented May 8, 2020

If you are doing in-proc processing of events with EventPipeEventSource and do something that creates an EventPipe provider, such as constructing a new EventSource, in your event processing callback it can deadlock.

The deadlock occurs when the EventPipeSession is being disabled and flushing the remaining contents to the stream, but the EventPipeEventSource thread that is in the middle of reading from the stream is trying to create a new provider. Both provider creation and session termination happen under the global EventPipe lock.

Further complicating this is that EventPipeEventSource is in managed code, so the developer may not be intentionally creating an EventSource. I ran in to it because Console.WriteLine triggered (through String.Format) the creation of ArrayPoolEventSource.

Here is the sample program that will deadlock

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Diagnostics.Tracing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using Microsoft.Diagnostics.NETCore.Client;
using Microsoft.Diagnostics.Tracing;
using Microsoft.Diagnostics.Tracing.Etlx;

namespace MultiThreadedApp
{
    [EventData]
    struct NestedSerializableClass
    {
        public int i;
    }

    [EventData]
    struct SerializableClass
    {
        public int i;
        public NestedSerializableClass nested;
        public DateTime time;
    }

    class MyEventSource : EventSource
    {
        public MyEventSource()
            : base(EventSourceSettings.EtwSelfDescribingEventFormat)
        {

        }

        [Event(1, Level = EventLevel.LogAlways)]
        public void IntEnumEvent(IEnumerable<int> simpleEnum)
        {
           WriteEvent(1, simpleEnum);
        }

        [Event(2, Level = EventLevel.LogAlways)]
        public void IntArrayEvent(int[] intArray)
        {
           WriteEvent(2, intArray);
        }

        [Event(3, Level = EventLevel.LogAlways)]
        public void BasicEvent(int i)
        {
            WriteEvent(3, i);
        }

        protected override void OnEventCommand(EventCommandEventArgs command)
        {
            Console.WriteLine($"command={command.Command}");
        }
    }

    class Program
    {
        public static EventPipeSession AttachEventPipeSessionToSelf(IEnumerable<EventPipeProvider> providers)
        {
            int processId = Process.GetCurrentProcess().Id;
            DiagnosticsClient client = new DiagnosticsClient(processId);
            return client.StartEventPipeSession(providers, /* requestRunDown */ false);
        }

        static void Main(string[] args)
        {
            try
            {
                List<EventPipeProvider> providers = new List<EventPipeProvider>
                {
                    new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Informational, (long)Keywords.Default),
                    new EventPipeProvider("MyEventSource", EventLevel.Verbose, (long)0xf00000000000)
                };

                using (EventPipeSession session = AttachEventPipeSessionToSelf(providers))
                {
                    WriteEvents();
                    ManualResetEvent allEventsReceivedEvent = new ManualResetEvent(false);

                    int eventCount = 0;
                    var source = new EventPipeEventSource(session.EventStream);
                    source.Dynamic.All += (TraceEvent traceEvent) =>
                    {
                        if (traceEvent.ProviderName != "Microsoft-Windows-DotNETRuntime")
                        {
                            Console.WriteLine($"{traceEvent.ToString()} Keywords={traceEvent.Keywords.ToString("X")} Opcode={traceEvent.Opcode}");
                        }

                        if (traceEvent.ProviderName != "MyEventSource")
                        {
                            return;
                        }

                        Console.WriteLine($"Got event {traceEvent.EventName} with payload count {traceEvent.PayloadNames.Length}");
                        ++eventCount;
                        if (eventCount == 3)
                        {
                            allEventsReceivedEvent.Set();
                        }
                    };

                    Thread processingThread = new Thread(new ThreadStart(() =>
                    {
                        source.Process();
                    }));

                    Console.WriteLine("Starting processing thread");
                    processingThread.Start();

                    session.Stop();

                    Console.WriteLine("Waiting on event");
                    allEventsReceivedEvent.WaitOne(TimeSpan.FromSeconds(5));
                    Console.WriteLine("Joining processing thread");
                    processingThread.Join();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"Got exception {e.Message} while processing events.");
            }
        }

        private static SerializableClass[] GenerateComplexArray()
        {
            Random rand = new Random();
            SerializableClass[] complexArray = new SerializableClass[1000];
            for (int i = 0; i < complexArray.Length; ++i)
            {
                SerializableClass temp = new SerializableClass()
                {
                    i = rand.Next(),
                    nested = new NestedSerializableClass()
                    {
                        i = rand.Next()
                    },
                    time = new DateTime((long)rand.NextDouble())
                };

                complexArray[i] = temp;
            }

            return complexArray;
        }

        private static void WriteEvents()
        {
            MyEventSource eventSource = new MyEventSource();

            Console.WriteLine("Writing events from MyEventSource");
            eventSource.BasicEvent(12);

            int[] intArray = Enumerable.Range(0, 100).ToArray();
            eventSource.IntArrayEvent(intArray);

            IEnumerable<int> intEnum = intArray;
            eventSource.IntEnumEvent(intEnum);

            Console.WriteLine("Done");
        }
    }
}

Here are the relevant deadlocked callstacks:

0:013> k
 # Child-SP          RetAddr           Call Site
00 0000001b`737f9dd8 00007ffe`75f67619 ntdll!ZwWaitForAlertByThreadId+0x14 [minkernel\ntdll\daytona\objfre\amd64\usrstubs.asm @ 3843] 
01 0000001b`737f9de0 00007ffe`75f674d2 ntdll!RtlpWaitOnAddressWithTimeout+0x81 [minkernel\ntos\rtl\waitaddr.c @ 851] 
02 0000001b`737f9e10 00007ffe`75f672fd ntdll!RtlpWaitOnAddress+0xae [minkernel\ntos\rtl\waitaddr.c @ 1094] 
03 0000001b`737f9e80 00007ffe`75f7b576 ntdll!RtlpWaitOnCriticalSection+0xfd [minkernel\ntos\rtl\resource.c @ 1610] 
04 0000001b`737f9f60 00007ffe`75f7b3c0 ntdll!RtlpEnterCriticalSectionContended+0x1a6 [minkernel\ntos\rtl\resource.c @ 2317] 
05 0000001b`737f9fc0 00007ffe`029bb8f5 ntdll!RtlEnterCriticalSection+0x40 [minkernel\ntos\rtl\resource.c @ 1923] 
06 0000001b`737f9ff0 00007ffe`0295078a CoreCLR!CrstBase::Enter+0x2d5 [C:\git\runtime\src\coreclr\src\vm\crst.cpp @ 328] 
07 0000001b`737fa0b0 00007ffe`0294f33a CoreCLR!CrstBase::AcquireLock+0x2a [C:\git\runtime\src\coreclr\src\vm\crst.h @ 189] 
08 0000001b`737fa0e0 00007ffe`02db0c84 CoreCLR!CrstBase::CrstHolder::CrstHolder+0x3a [C:\git\runtime\src\coreclr\src\vm\crst.h @ 383] 
09 0000001b`737fa110 00007ffe`02db23f0 CoreCLR!EventPipe::RunWithCallbackPostponed<<lambda_2125f3f70d5d26418c21758b8d2774c4> >+0x44 [C:\git\runtime\src\coreclr\src\vm\eventpipe.h @ 133] 
0a 0000001b`737fa220 00007ffe`032c4257 CoreCLR!EventPipe::CreateProvider+0x2e0 [C:\git\runtime\src\coreclr\src\vm\eventpipe.cpp @ 567] 
0b 0000001b`737fa430 00007ffe`01eb6432 CoreCLR!EventPipeInternal::CreateProvider+0x237 [C:\git\runtime\src\coreclr\src\vm\eventpipeinternal.cpp @ 100] 
0c 0000001b`737fa640 00007ffe`02308320 System.Diagnostics.Tracing.EventPipeInternal.CreateProvider(System.String, EtwEnableCallback)+0x82
0d 0000001b`737fa730 00007ffe`0231092a System_Private_CoreLib!System.Diagnostics.Tracing.EventPipeEventProvider.System.Diagnostics.Tracing.IEventProvider.EventRegister(System.Diagnostics.Tracing.EventSource, EtwEnableCallback, Void*, Int64 ByRef)+0x50 [C:\git\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventPipeEventProvider.cs @ 20] 
0e 0000001b`737fa790 00007ffe`0230cc04 System_Private_CoreLib!System.Diagnostics.Tracing.EventProvider.EventRegister(System.Diagnostics.Tracing.EventSource, EtwEnableCallback)+0xba [C:\git\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventProvider.cs @ 1226] 
0f 0000001b`737fa800 00007ffe`02315a72 System_Private_CoreLib!System.Diagnostics.Tracing.EventProvider.Register(System.Diagnostics.Tracing.EventSource)+0x64 [C:\git\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventProvider.cs @ 149] 
10 0000001b`737fa860 00007ffe`0231576e System_Private_CoreLib!System.Diagnostics.Tracing.EventSource.Initialize(System.Guid, System.String, System.String[])+0x2f2 [C:\git\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventSource.cs @ 1459] 
11 0000001b`737faa00 00007ffe`0231564e System_Private_CoreLib!System.Diagnostics.Tracing.EventSource..ctor(System.Guid, System.String, System.Diagnostics.Tracing.EventSourceSettings, System.String[])+0x10e [C:\git\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventSource.cs @ 1409] 
12 0000001b`737faa70 00007ffe`02061cf4 System_Private_CoreLib!System.Diagnostics.Tracing.EventSource..ctor(System.Guid, System.String)+0x4e [C:\git\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventSource.cs @ 1402] 
13 0000001b`737faac0 00007ffe`02062334 System_Private_CoreLib!System.Buffers.ArrayPoolEventSource..ctor()+0xa4 [C:\git\runtime\src\libraries\System.Private.CoreLib\src\System\Buffers\ArrayPoolEventSource.cs @ 26] 
14 0000001b`737fab60 00007ffe`032b8723 System_Private_CoreLib!System.Buffers.ArrayPoolEventSource..cctor()+0x24 [C:\git\runtime\src\libraries\System.Private.CoreLib\src\System\Buffers\ArrayPoolEventSource.cs @ 12] 
15 0000001b`737faba0 00007ffe`02e998f2 CoreCLR!CallDescrWorkerInternal+0x83 [C:\git\runtime\src\coreclr\src\vm\amd64\CallDescrWorkerAMD64.asm @ 101] 
16 0000001b`737fabe0 00007ffe`02e9adf3 CoreCLR!CallDescrWorkerWithHandler+0x142 [C:\git\runtime\src\coreclr\src\vm\callhelpers.cpp @ 73] 
17 0000001b`737fac40 00007ffe`02e9a6a4 CoreCLR!`DispatchCallDebuggerWrapper'::`6'::__Body::Run+0x63 [C:\git\runtime\src\coreclr\src\vm\callhelpers.cpp @ 159] 
18 0000001b`737fac90 00007ffe`02e9a977 CoreCLR!DispatchCallDebuggerWrapper+0x74 [C:\git\runtime\src\coreclr\src\vm\callhelpers.cpp @ 163] 
19 0000001b`737fad30 00007ffe`02efc3a4 CoreCLR!DispatchCallSimple+0x257 [C:\git\runtime\src\coreclr\src\vm\callhelpers.cpp @ 221] 
1a 0000001b`737faec0 00007ffe`02edf987 CoreCLR!MethodTable::RunClassInitEx+0x604 [C:\git\runtime\src\coreclr\src\vm\methodtable.cpp @ 3112] 
1b 0000001b`737fb300 00007ffe`02ed8817 CoreCLR!MethodTable::DoRunClassInitThrowing+0x8e7 [C:\git\runtime\src\coreclr\src\vm\methodtable.cpp @ 3302] 
1c 0000001b`737fc2a0 00007ffe`02c79c45 CoreCLR!MethodTable::CheckRunClassInitThrowing+0x4b7 [C:\git\runtime\src\coreclr\src\vm\methodtable.cpp @ 3442] 
1d 0000001b`737fc4e0 00007ffe`02c862ea CoreCLR!DynamicHelperFixup+0x545 [C:\git\runtime\src\coreclr\src\vm\prestub.cpp @ 3177] 
1e 0000001b`737fcc00 00007ffe`03143b5a CoreCLR!DynamicHelperWorker+0x29a [C:\git\runtime\src\coreclr\src\vm\prestub.cpp @ 3484] 
1f 0000001b`737fcfb0 00007ffe`02495eca CoreCLR!DelayLoad_Helper+0x7a [C:\git\runtime\src\coreclr\src\vm\amd64\ExternalMethodFixupThunk.asm @ 87] 
20 0000001b`737fd070 00007ffe`021114e8 System_Private_CoreLib!System.Buffers.TlsOverPerCoreLockedStacksArrayPool`1[[System.Char, System.Private.CoreLib]].Rent(Int32)+0xda [C:\git\runtime\src\libraries\System.Private.CoreLib\src\System\Buffers\TlsOverPerCoreLockedStacksArrayPool.cs @ 97] 
21 0000001b`737fd200 00007ffe`02110ebc System_Private_CoreLib!System.Text.ValueStringBuilder.Grow(Int32)+0xf8 [C:\git\runtime\src\libraries\Common\src\System\Text\ValueStringBuilder.cs @ 287] 
22 0000001b`737fd300 00007ffe`02110dee System_Private_CoreLib!System.Text.ValueStringBuilder.AppendSlow(System.String)+0xbc [C:\git\runtime\src\libraries\Common\src\System\Text\ValueStringBuilder.cs @ 203] 
23 0000001b`737fd3c0 00007ffe`021101c2 System_Private_CoreLib!System.Text.ValueStringBuilder.Append(System.String)+0xee [C:\git\runtime\src\libraries\Common\src\System\Text\ValueStringBuilder.cs @ 194] 
24 0000001b`737fd420 00007ffe`01f1d381 System_Private_CoreLib!System.Text.ValueStringBuilder.AppendFormatHelper(System.IFormatProvider, System.String, System.ParamsArray)+0xcc2 [C:\git\runtime\src\libraries\System.Private.CoreLib\src\System\Text\ValueStringBuilder.AppendFormat.cs @ 341] 
25 0000001b`737fd6f0 00007ffe`01f1cdac System_Private_CoreLib!System.String.FormatHelper(System.IFormatProvider, System.String, System.ParamsArray)+0x1d1 [C:\git\runtime\src\libraries\System.Private.CoreLib\src\System\String.Manipulation.cs @ 528] 
26 0000001b`737fd9f0 00007ffd`a4932b51 System_Private_CoreLib!System.String.Format(System.String, System.Object, System.Object, System.Object)+0x7c [C:\git\runtime\src\libraries\System.Private.CoreLib\src\System\String.Manipulation.cs @ 479] 
27 0000001b`737fda80 00007ffd`a4932a34 arraytypesapp!MultiThreadedApp.Program+<>c__DisplayClass1_0.<Main>b__0(Microsoft.Diagnostics.Tracing.TraceEvent)+0xf1 [C:\work\arraytypes_test\arraytypesapp\Program.cs @ 104] 
28 0000001b`737fdaf0 00007ffd`a4932649 microsoft_diagnostics_tracing_traceevent!Microsoft.Diagnostics.Tracing.Parsers.DynamicTraceEventData.Dispatch()+0x64 [C:\git\perfview\src\TraceEvent\DynamicTraceEventParser.cs @ 539] 
29 0000001b`737fdb30 00007ffd`a4932553 microsoft_diagnostics_tracing_traceevent!Microsoft.Diagnostics.Tracing.TraceEventDispatcher.DoDispatch(Microsoft.Diagnostics.Tracing.TraceEvent)+0x99 [C:\git\perfview\src\TraceEvent\TraceEvent.cs @ 3418] 
2a 0000001b`737fdc10 00007ffd`a49220d3 microsoft_diagnostics_tracing_traceevent!Microsoft.Diagnostics.Tracing.TraceEventDispatcher.Dispatch(Microsoft.Diagnostics.Tracing.TraceEvent)+0x53 [C:\git\perfview\src\TraceEvent\TraceEvent.cs @ 3400] 
2b 0000001b`737fdc50 00007ffd`a49251ea microsoft_diagnostics_tracing_traceevent!Microsoft.Diagnostics.Tracing.EventPipeEventSource.DispatchEventRecord(EVENT_RECORD*)+0xe3 [C:\git\perfview\src\TraceEvent\EventPipe\EventPipeEventSource.cs @ 182] 
2c 0000001b`737fdca0 00007ffd`a4924a82 microsoft_diagnostics_tracing_traceevent!Microsoft.Diagnostics.Tracing.EventPipeEventSource.EventCache_OnEvent(Microsoft.Diagnostics.Tracing.EventPipeEventHeader ByRef)+0xda [C:\git\perfview\src\TraceEvent\EventPipe\EventPipeEventSource.cs @ 391] 
2d 0000001b`737fdd10 00007ffd`a4923a74 microsoft_diagnostics_tracing_traceevent!Microsoft.Diagnostics.Tracing.EventPipe.EventCache.SortAndDispatch(Int64)+0x352 [C:\git\perfview\src\TraceEvent\EventPipe\EventCache.cs @ 197] 
2e 0000001b`737fdea0 00007ffd`a4923540 microsoft_diagnostics_tracing_traceevent!Microsoft.Diagnostics.Tracing.EventPipe.EventCache.ProcessEventBlock(Byte[])+0x4b4 [C:\git\perfview\src\TraceEvent\EventPipe\EventCache.cs @ 85] 
2f 0000001b`737fe000 00007ffd`a491cf75 microsoft_diagnostics_tracing_traceevent!Microsoft.Diagnostics.Tracing.EventPipeEventBlock.ReadBlockContents(FastSerialization.PinnedStreamReader)+0xf0 [C:\git\perfview\src\TraceEvent\EventPipe\EventPipeEventSource.cs @ 814] 
30 0000001b`737fe070 00007ffd`a4237838 microsoft_diagnostics_tracing_traceevent!Microsoft.Diagnostics.Tracing.EventPipeBlock.FromStream(FastSerialization.Deserializer)+0x185 [C:\git\perfview\src\TraceEvent\EventPipe\EventPipeEventSource.cs @ 774] 
31 0000001b`737fe120 00007ffd`a4237c98 microsoft_diagnostics_fastserialization!FastSerialization.Deserializer.ReadObjectDefinition(FastSerialization.Tags, FastSerialization.StreamLabel)+0x448 [C:\git\perfview\src\FastSerialization\FastSerialization.cs @ 1904] 
32 0000001b`737fe230 00007ffd`a491ca59 microsoft_diagnostics_fastserialization!FastSerialization.Deserializer.ReadObject()+0x3e8 [C:\git\perfview\src\FastSerialization\FastSerialization.cs @ 1356] 
33 0000001b`737fe360 00007ffd`a491c751 microsoft_diagnostics_tracing_traceevent!Microsoft.Diagnostics.Tracing.EventPipeEventSource.Process()+0x89 [C:\git\perfview\src\TraceEvent\EventPipe\EventPipeEventSource.cs @ 128] 
34 0000001b`737fe410 00007ffe`02081db1 arraytypesapp!MultiThreadedApp.Program+<>c__DisplayClass1_0.<Main>b__1()+0x31 [C:\work\arraytypes_test\arraytypesapp\Program.cs @ 123] 
35 0000001b`737fe450 00007ffe`0209175f System_Private_CoreLib!System.Threading.ThreadHelper.ThreadStart_Context(System.Object)+0xd1 [C:\git\runtime\src\coreclr\src\System.Private.CoreLib\src\System\Threading\Thread.CoreCLR.cs @ 43] 
36 0000001b`737fe4b0 00007ffe`02081fdc System_Private_CoreLib!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)+0x13f [C:\git\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\ExecutionContext.cs @ 172] 
37 0000001b`737fe580 00007ffe`032b8723 System_Private_CoreLib!System.Threading.ThreadHelper.ThreadStart()+0x7c [C:\git\runtime\src\coreclr\src\System.Private.CoreLib\src\System\Threading\Thread.CoreCLR.cs @ 92] 
38 0000001b`737fe5d0 00007ffe`02e998f2 CoreCLR!CallDescrWorkerInternal+0x83 [C:\git\runtime\src\coreclr\src\vm\amd64\CallDescrWorkerAMD64.asm @ 101] 
39 0000001b`737fe610 00007ffe`02e9a570 CoreCLR!CallDescrWorkerWithHandler+0x142 [C:\git\runtime\src\coreclr\src\vm\callhelpers.cpp @ 73] 
3a 0000001b`737fe670 00007ffe`0295a838 CoreCLR!MethodDescCallSite::CallTargetWorker+0xc70 [C:\git\runtime\src\coreclr\src\vm\callhelpers.cpp @ 549] 
3b 0000001b`737feed0 00007ffe`031255f3 CoreCLR!MethodDescCallSite::Call+0x38 [C:\git\runtime\src\coreclr\src\vm\callhelpers.h @ 459] 
3c 0000001b`737fef00 00007ffe`02b28d55 CoreCLR!ThreadNative::KickOffThread_Worker+0x4b3 [C:\git\runtime\src\coreclr\src\vm\comsynchronizable.cpp @ 248] 
3d 0000001b`737ff240 00007ffe`02b28dfe CoreCLR!ManagedThreadBase_DispatchInner+0x1a5 [C:\git\runtime\src\coreclr\src\vm\threads.cpp @ 7333] 
3e 0000001b`737ff360 00007ffe`02b2d65b CoreCLR!ManagedThreadBase_DispatchMiddle+0x7e [C:\git\runtime\src\coreclr\src\vm\threads.cpp @ 7377] 
3f 0000001b`737ff660 00007ffe`02b2da4a CoreCLR!``ManagedThreadBase_DispatchOuter'::`11'::__Body::Run'::`5'::__Body::Run+0x5b [C:\git\runtime\src\coreclr\src\vm\threads.cpp @ 7536] 
40 0000001b`737ff6b0 00007ffe`02b28f51 CoreCLR!`ManagedThreadBase_DispatchOuter'::`11'::__Body::Run+0x8a [C:\git\runtime\src\coreclr\src\vm\threads.cpp @ 7538] 
41 0000001b`737ff750 00007ffe`02b29134 CoreCLR!ManagedThreadBase_DispatchOuter+0x111 [C:\git\runtime\src\coreclr\src\vm\threads.cpp @ 7560] 
42 0000001b`737ff860 00007ffe`02b28738 CoreCLR!ManagedThreadBase_FullTransition+0x1b4 [C:\git\runtime\src\coreclr\src\vm\threads.cpp @ 7584] 
43 0000001b`737ff9b0 00007ffe`03125027 CoreCLR!ManagedThreadBase::KickOff+0x38 [C:\git\runtime\src\coreclr\src\vm\threads.cpp @ 7620] 
44 0000001b`737ff9e0 00007ffe`74027bd4 CoreCLR!ThreadNative::KickOffThread+0x2b7 [C:\git\runtime\src\coreclr\src\vm\comsynchronizable.cpp @ 328] 
45 0000001b`737ffc20 00007ffe`75fcce51 KERNEL32!BaseThreadInitThunk+0x14 [base\win32\client\thread.c @ 64] 
46 0000001b`737ffc50 00000000`00000000 ntdll!RtlUserThreadStart+0x21 [minkernel\ntdll\rtlstrt.c @ 1153] 
0:013> ~6k
 # Child-SP          RetAddr           Call Site
00 0000001b`7307e538 00007ffe`73c8203d ntdll!ZwFlushBuffersFile+0x14 [minkernel\ntdll\daytona\objfre\amd64\usrstubs.asm @ 779] 
01 0000001b`7307e540 00007ffe`0381f90c KERNELBASE!FlushFileBuffers+0x2d [minkernel\kernelbase\filehops.c @ 2349] 
02 0000001b`7307e580 00007ffe`0381f4f3 CoreCLR!IpcStream::Flush+0x2c [C:\git\runtime\src\coreclr\src\debug\debug-pal\win\diagnosticsipc.cpp @ 159] 
03 0000001b`7307e5c0 00007ffe`02dae84c CoreCLR!IpcStream::~IpcStream+0x33 [C:\git\runtime\src\coreclr\src\debug\debug-pal\win\diagnosticsipc.cpp @ 107] 
04 0000001b`7307e600 00007ffe`034adaaa CoreCLR!IpcStream::`scalar deleting destructor'+0x2c
05 0000001b`7307e630 00007ffe`034adb9c CoreCLR!IpcStreamWriter::~IpcStreamWriter+0x1ba [C:\git\runtime\src\coreclr\src\vm\fastserializer.cpp @ 42] 
06 0000001b`7307e760 00007ffe`034ad686 CoreCLR!IpcStreamWriter::`scalar deleting destructor'+0x2c
07 0000001b`7307e790 00007ffe`034c125c CoreCLR!FastSerializer::~FastSerializer+0x1c6 [C:\git\runtime\src\coreclr\src\vm\fastserializer.cpp @ 143] 
08 0000001b`7307e8c0 00007ffe`034c0170 CoreCLR!FastSerializer::`scalar deleting destructor'+0x2c
09 0000001b`7307e8f0 00007ffe`032a7c9c CoreCLR!EventPipeFile::~EventPipeFile+0x3b0 [C:\git\runtime\src\coreclr\src\vm\eventpipefile.cpp @ 181] 
0a 0000001b`7307eb00 00007ffe`032a7bb8 CoreCLR!EventPipeFile::`scalar deleting destructor'+0x2c
0b 0000001b`7307eb30 00007ffe`02db1d3c CoreCLR!EventPipeSession::~EventPipeSession+0x328 [C:\git\runtime\src\coreclr\src\vm\eventpipesession.cpp @ 93] 
0c 0000001b`7307ecf0 00007ffe`02db31fd CoreCLR!EventPipeSession::`scalar deleting destructor'+0x2c
0d 0000001b`7307ed20 00007ffe`02db1c48 CoreCLR!EventPipe::DisableInternal+0x6ad [C:\git\runtime\src\coreclr\src\vm\eventpipe.cpp @ 527] 
0e 0000001b`7307eff0 00007ffe`02db0e17 CoreCLR!<lambda_bdfbdf0d3cafb5823bb854972735cdb5>::operator()+0x48 [C:\git\runtime\src\coreclr\src\vm\eventpipe.cpp @ 436] 
0f 0000001b`7307f020 00007ffe`02db2b10 CoreCLR!EventPipe::RunWithCallbackPostponed<<lambda_bdfbdf0d3cafb5823bb854972735cdb5> >+0x57 [C:\git\runtime\src\coreclr\src\vm\eventpipe.h @ 134] 
10 0000001b`7307f130 00007ffe`0329aff5 CoreCLR!EventPipe::Disable+0x1e0 [C:\git\runtime\src\coreclr\src\vm\eventpipe.cpp @ 433] 
11 0000001b`7307f2f0 00007ffe`0329a8aa CoreCLR!EventPipeProtocolHelper::StopTracing+0x355 [C:\git\runtime\src\coreclr\src\vm\eventpipeprotocolhelper.cpp @ 204] 
12 0000001b`7307f560 00007ffe`02daedab CoreCLR!EventPipeProtocolHelper::HandleIpcMessage+0x2fa [C:\git\runtime\src\coreclr\src\vm\eventpipeprotocolhelper.cpp @ 132] 
13 0000001b`7307f700 00007ffe`74027bd4 CoreCLR!DiagnosticServer::DiagnosticsServerThread+0x51b [C:\git\runtime\src\coreclr\src\vm\diagnosticserver.cpp @ 77] 
14 0000001b`7307fa30 00007ffe`75fcce51 KERNEL32!BaseThreadInitThunk+0x14 [base\win32\client\thread.c @ 64] 
15 0000001b`7307fa60 00000000`00000000 ntdll!RtlUserThreadStart+0x21 [minkernel\ntdll\rtlstrt.c @ 1153] 
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-Tracing-coreclr untriaged New issue has not been triaged by the area owner labels May 8, 2020
@davmason
Copy link
Member Author

davmason commented May 8, 2020

I haven't thought about the solution much. It would be nice if we could flush the session's stream outside of the global lock, I imagine that this isn't the only scenario where we could run in to issues. Another option would be to rework EventPipeEventSource so it finished reading from the stream before calling user's callbacks.

Right now I'm filing this as a placeholder so I can finish the array type work.

@tommcdon tommcdon added p1 and removed untriaged New issue has not been triaged by the area owner labels May 11, 2020
@tommcdon tommcdon added this to the 5.0 milestone May 11, 2020
@davmason
Copy link
Member Author

Dupe of #1892

@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants