Add NoInlining and NoOptimization attributes to ClearWaitSleepJoinState method#122652
Merged
Add NoInlining and NoOptimization attributes to ClearWaitSleepJoinState method#122652
Conversation
…te method Co-authored-by: jkotas <[email protected]>
Copilot
AI
changed the title
[WIP] Annotate ClearWaitSleepJoinState method with NoInlining and NoOptimization
Add NoInlining and NoOptimization attributes to ClearWaitSleepJoinState method
Dec 18, 2025
jkotas
reviewed
Dec 18, 2025
src/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs
Outdated
Show resolved
Hide resolved
Member
|
/azp run runtime-coreclr gcstress-extra |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Member
|
cc @dotnet/jit-contrib This is causing a lot of noise in GC stress. Suppressing optimizations as a quick workaround. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements a temporary workaround for issue #122479 by disabling compiler optimizations on the ClearWaitSleepJoinState() method to prevent runtime failures related to thread state transitions.
Key changes:
- Added
MethodImplattribute withNoInlining | NoOptimizationflags to prevent problematic compiler optimizations - Added explanatory comment linking to the tracked issue
AndyAyersMS
approved these changes
Dec 21, 2025
Member
|
/ba-g infrastructure timeout |
This was referenced Jan 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Temporary workaround for issue #122479 by marking
Thread.ClearWaitSleepJoinState()withMethodImplOptions.NoInlining | MethodImplOptions.NoOptimizationto prevent compiler optimizations that trigger the underlying issue.Changes:
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]toClearWaitSleepJoinState()insrc/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.csCustomer Impact
Without this fix, customers may experience runtime failures related to thread wait/sleep/join state transitions under specific optimization scenarios.
Regression
No - this is a workaround for an existing issue, not a regression fix.
Testing
Risk
Low. The change is minimal (3 lines) and only disables optimizations for a single internal method. This reduces performance optimization potential for this specific method but has no functional impact. The attributes are defensive and prevent the compiler from introducing problematic optimizations.
Original prompt
This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.