Skip to content

Fix Debug.Assert failures in SpeedScope tests and DynamicTraceEventParser#2368

Merged
brianrob merged 1 commit into
microsoft:mainfrom
brianrob:brianrob/throwsexception-test
Feb 23, 2026
Merged

Fix Debug.Assert failures in SpeedScope tests and DynamicTraceEventParser#2368
brianrob merged 1 commit into
microsoft:mainfrom
brianrob:brianrob/throwsexception-test

Conversation

@brianrob
Copy link
Copy Markdown
Member

@brianrob brianrob commented Feb 20, 2026

The SpeedScope CanConvertProvidedTraceFiles tests were clearing Trace.Listeners to suppress Debug.Assert failures that fired during trace parsing. This masked two real bugs:

Fix 1: Duplicate template enumeration in DynamicTraceEventParser

DynamicTraceEventParser.EnumerateTemplates enumerates templates from three sources (manifest-based, registeredParser, and eventPipeTraceEventParser) but only deduplicated between manifest-based templates and registeredParser. When both registeredParser and eventPipeTraceEventParser knew about the same event, the template was enumerated twice, causing Subscribe to assert on the duplicate with mayHaveExistedBefore=false.

Fix: Filter eventPipeTraceEventParser templates against registeredParser, matching the existing dedup pattern for manifest-based templates.

Fix 2: Skip ConfirmAllEventsAreInEnumeration for ApplicationServerTraceEventParser

ApplicationServerTraceEventParser is auto-generated and has many events that share the same task name and opcode, producing duplicate computed event names (100+ duplicates). The ConfirmAllEventsAreInEnumeration DEBUG validation cannot handle this pattern.

Fix: Skip this parser from the validation, similar to how PredefinedDynamicTraceEventParser is already excluded.

Cleanup

  • Remove the listener-clearing hack from SpeedScope tests (no longer needed since the underlying asserts are fixed).
  • Add documentation to ThrowingTraceListener and DebugAssertionTests explaining that on .NET 5+, the DefaultTraceListener already throws on assert failures, so no additional listener configuration is needed.

@brianrob
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@brianrob
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@brianrob
Copy link
Copy Markdown
Member Author

/azp run

1 similar comment
@brianrob
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@brianrob
Copy link
Copy Markdown
Member Author

/azp run

1 similar comment
@brianrob
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@brianrob
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@brianrob
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@brianrob
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@brianrob
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@brianrob
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@brianrob
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@brianrob
Copy link
Copy Markdown
Member Author

/azp run

1 similar comment
@brianrob
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@brianrob
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
Collaborator

@leculver leculver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with 1 comment.

// cannot handle.
if (GetProviderName() != null && !m_ConfirmedAllEventsAreInEnumeration &&
!(this is PredefinedDynamicTraceEventParser) &&
!(this is Parsers.ApplicationServerTraceEventParser))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fragile. Fine for now, but if you find you need another class it might be time to think through the design.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. I agree that if this gets bigger we should look to make this a real pattern.

@brianrob brianrob merged commit ddcaf39 into microsoft:main Feb 23, 2026
5 checks passed
@brianrob brianrob deleted the brianrob/throwsexception-test branch February 23, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants