EventSource Events that use complex types do not get logged (silently ignored)
authorVance Morrison <vancemorrison@comcast.net>
Fri, 27 May 2016 00:15:14 +0000 (17:15 -0700)
committerVance Morrison <vancemorrison@comcast.net>
Fri, 27 May 2016 00:15:14 +0000 (17:15 -0700)
When complex types were added to EventSource (in V4.6) there was a latent bug where if the event had specified keywords
the event would not be emitted to TraceEvent-style ETW controlers (e.g. PerfVIew).    Basically there was confusion
between a session bitmask (where the bits were 0, 1, 2,  and 3), and the ETW keywords bitmask (which the 'ToEventKeywords()
morphs them to a Keywords Bitmask.)

This bug has existed foa a while, but we are now using both of those features (keywords and complex types), in the
DiagnosticEventSource and when we started to really use it we found the problem.

You will see in lines 1221 and 1242 is another code path that was already fixed, but we missed the cose path at 1977 and 1998.

This needs to be back-ported to the Desktop framework as well.

Commit migrated from https://github.com/dotnet/coreclr/commit/42e6d1acf462c91ef8fa99b0953bee8ffd608240

src/coreclr/src/mscorlib/src/System/Diagnostics/Eventing/EventSource.cs

index 73b23bc..28c50a8 100644 (file)
@@ -1974,7 +1974,7 @@ namespace System.Diagnostics.Tracing
                                         m_eventData[eventId].Descriptor.Level,
                                         m_eventData[eventId].Descriptor.Opcode,
                                         m_eventData[eventId].Descriptor.Task,
-                                        unchecked((long)(ulong)etwSessions | origKwd));
+                                        unchecked((long)etwSessions.ToEventKeywords() | origKwd));
 
                                     if (!m_provider.WriteEvent(ref desc, pActivityId, childActivityID, args))
                                         ThrowEventSourceException(m_eventData[eventId].Name);
@@ -1995,7 +1995,7 @@ namespace System.Diagnostics.Tracing
                                 // TODO: activity ID support
                                 EventSourceOptions opt = new EventSourceOptions
                                 {
-                                    Keywords = (EventKeywords)unchecked((long)(ulong)etwSessions | origKwd),
+                                    Keywords = (EventKeywords)unchecked((long)etwSessions.ToEventKeywords() | origKwd),
                                     Level = (EventLevel)m_eventData[eventId].Descriptor.Level,
                                     Opcode = (EventOpcode)m_eventData[eventId].Descriptor.Opcode
                                 };