Skip to content

Conversation

tommcdon
Copy link
Member

Fixes #111182
This change avoids reporting contexts generated from EEPolicy::HandleFatalError to Watson

@tommcdon tommcdon requested review from Copilot, jkotas and noahfalk July 10, 2025 21:42
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR prevents Watson from receiving an incorrect thread context when RaiseFailFastException is invoked for fatal errors.

  • Adds a boolean flag to detect fatal-error contexts.
  • Updates the ContextRecord argument in RaiseFailFastException to pass NULL when the flag is set.
Comments suppressed due to low confidence (1)

src/coreclr/vm/excep.cpp:3570

  • [nitpick] Consider renaming fAvoidReportContextToRaiseFailFast to a shorter, more descriptive name (e.g. fSkipContextReport or skipContextForFatalError) to improve readability.
                bool fAvoidReportContextToRaiseFailFast = tore.IsFatalError(); // avoid reporting incorrect thread context to Watson

@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jul 10, 2025
@tommcdon tommcdon added area-Diagnostics-coreclr and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Jul 10, 2025
Copy link
Contributor

Tagging subscribers to this area: @steveisok, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

@jkotas
Copy link
Member

jkotas commented Jul 13, 2025

We had to play games with context passed to Watson on win x86 - see dotnet/coreclr#23289 . You may want to double check that Watson and dump debugging on win x86 works well with this change.

@tommcdon
Copy link
Member Author

We had to play games with context passed to Watson on win x86 - see dotnet/coreclr#23289 . You may want to double check that Watson and dump debugging on win x86 works well with this change.

Verified !analyze works as expected on a Windows Error Reported collect dump of an x86 test app calling Environment.FailFast, which invokes the FatalError code path:

EXCEPTION_RECORD:  (.exr -1)
ExceptionAddress: 083b2f3c (ConsoleApp1!Program.<<Main>$>g__Function5|0_4+0x00000054)
   ExceptionCode: 80131623
  ExceptionFlags: 00000001
NumberParameters: 0

PROCESS_NAME:  ConsoleApp1.dll
.
.
.
STACK_TEXT:  
0257f27c 6a0574ec System_Private_CoreLib!System.Environment.FailFast+0x3c
0257f2dc 6a05749f System_Private_CoreLib!System.Environment.FailFast+0xf
0257f2e8 6a057448 System_Private_CoreLib!System.Environment.FailFast+0x18
0257f2f0 083b2f3c ConsoleApp1!Program.<<Main>$>g__Function5|0_4+0x54
0257f308 083b2eca ConsoleApp1!Program.<<Main>$>g__Function4|0_3+0x3a
0257f320 083b2e72 ConsoleApp1!Program.<<Main>$>g__Function3|0_2+0x3a
0257f338 083b2e1a ConsoleApp1!Program.<<Main>$>g__Function2|0_1+0x3a
0257f350 083b2dc2 ConsoleApp1!Program.<<Main>$>g__Function1|0_0+0x3a
0257f368 083b2d2b ConsoleApp1!Program.<Main>$+0x3b

@tommcdon tommcdon merged commit 58121ac into dotnet:main Jul 15, 2025
98 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Aug 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EEPolicy::HandleFatalError calls RaiseFailFastException with invalid context

2 participants