You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
EventPipeEventSource constructor blocks until the first event is read #1172
If you follow the sample code on how to use EventPipeEventSource but replace the provider with a provider that doesn't produce any events, it will block forever in the constructor to EventPipeEventSource.
varproviders=newList<EventPipeProvider>(){newEventPipeProvider("Microsoft-Windows-DotNETRuntime",EventLevel.Informational,(long)ClrTraceEventParser.Keywords.GC)};varclient=newDiagnosticsClient(processId);using(varsession=client.StartEventPipeSession(providers,false)){varsource=newEventPipeEventSource(session.EventStream);source.Clr.All+=(TraceEventobj)=>{Console.WriteLine(obj.EventName);}try{source.Process();}// NOTE: This exception does not currently exist. It is something that needs to be added to TraceEvent.catch(EventStreamExceptione){Console.WriteLine("Error encountered while processing events");Console.WriteLine(e.ToString());}}
varentryObj=_deserializer.GetEntryObject();// this call invokes FromStream and reads header data
This seems like a pitfall, and it's not clear what is happening. I've used that code pattern lots before and it's never failed, then all of a sudden it hangs my app and I have to do a lot of digging to understand why. I imagine customers will run in to it as well.
Reacted by Yusuke Ito, Raf (Raffaele Rialdi) and Fabien Barbier
This is very problematic when we try to hook the very first events coming from a process.
As the constructor is blocked, the events cannot be subscribed and therefore there is a high chance to lose the first events.
John Salem (@josalem) can you take a look at this now that Sung Yoon Whang (@sywhang) is no longer at Microsoft? Thinking about this one a bit, I think that it's reasonable to block when waiting for the next event after Process is called, but we shouldn't be blocking in the constructor. This would be consistent with how ETW real-time sessions work.
Can do. This is a recurring issue and is unexpected behavior I would argue. I think care may need to be taken on "fixing" this, however, as this has been the behavior for a long while and changing it without an opt-in has the potential to break existing tools if they update their TraceEvent version.
Thanks John. To be honest, I'm not concerned about putting this behind a flag unless it has other more far reaching implications. If you're concerned, one thing you could consider is submitting it to the feature/perfview-3.0 branch. I'm batching up some larger changes that I'm going to release with a 3.0 version, and so this could be part of that.
+1 to not requiring a flag. It is technically a behavior change, but it's hard to imagine anyone relying on it.
I have helped multiple people figure out why their code was seemingly deadlocked, it is hard/impossible for someone unfamiliar with the internal of TraceEvent to figure out what is happening.
Activity
raffaeler commentedon Dec 10, 2020
This is very problematic when we try to hook the very first events coming from a process.
As the constructor is blocked, the events cannot be subscribed and therefore there is a high chance to lose the first events.
brianrob commentedon Jan 12, 2021
Sung Yoon Whang (@sywhang), are you planning to fix this? If I understand correctly, this sounds like an issue that is specific to live sessions.
sywhang commentedon Jan 12, 2021
Sure. I can take a look at this some time this week.
brianrob commentedon Jan 12, 2021
Thanks much Sung Yoon Whang (@sywhang).
mwasplund-msft commentedon Dec 7, 2021
It looks like Sung Yoon Whang (@sywhang) is no longer at Microsoft, Brian Robbins (@brianrob) can someone else take a look at this?
brianrob commentedon Jan 3, 2022
John Salem (@josalem) can you take a look at this now that Sung Yoon Whang (@sywhang) is no longer at Microsoft? Thinking about this one a bit, I think that it's reasonable to block when waiting for the next event after Process is called, but we shouldn't be blocking in the constructor. This would be consistent with how ETW real-time sessions work.
josalem commentedon Jan 3, 2022
Can do. This is a recurring issue and is unexpected behavior I would argue. I think care may need to be taken on "fixing" this, however, as this has been the behavior for a long while and changing it without an opt-in has the potential to break existing tools if they update their TraceEvent version.
brianrob commentedon Jan 3, 2022
Thanks John. To be honest, I'm not concerned about putting this behind a flag unless it has other more far reaching implications. If you're concerned, one thing you could consider is submitting it to the feature/perfview-3.0 branch. I'm batching up some larger changes that I'm going to release with a 3.0 version, and so this could be part of that.
davmason commentedon Jan 4, 2022
+1 to not requiring a flag. It is technically a behavior change, but it's hard to imagine anyone relying on it.
I have helped multiple people figure out why their code was seemingly deadlocked, it is hard/impossible for someone unfamiliar with the internal of TraceEvent to figure out what is happening.