Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 18, 2025

Description

Temporary workaround for issue #122479 by marking Thread.ClearWaitSleepJoinState() with MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization to prevent compiler optimizations that trigger the underlying issue.

Changes:

Customer 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

  • CoreCLR builds successfully with the changes
  • System.Threading.Thread.Tests pass (53 tests, 0 failures)

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

Mark the ClearWaitSleepJoinState method in Thread.CoreCLR.cs with the NoInlining and NoOptimization attributes as a temporary workaround for issue #122479 (#122479).

Acceptance Criteria:

  • The System.Threading.Thread.ClearWaitSleepJoinState() method implementation in src/libraries/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs is annotated with both [MethodImpl(MethodImplOptions.NoInlining)] and [MethodImpl(MethodImplOptions.NoOptimization)] attributes.
  • Add a comment above the method referencing the issue and indicating that this is a temporary workaround.
  • No unrelated changes are included.
  • A brief PR description referencing the workaround and the issue.

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.

@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 Dec 18, 2025
…te method

Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Copilot AI changed the title [WIP] Annotate ClearWaitSleepJoinState method with NoInlining and NoOptimization Add NoInlining and NoOptimization attributes to ClearWaitSleepJoinState method Dec 18, 2025
Copilot AI requested a review from jkotas December 18, 2025 22:01
@jkotas
Copy link
Member

jkotas commented Dec 18, 2025

/azp run runtime-coreclr gcstress-extra

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jkotas jkotas added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Dec 18, 2025
@jkotas jkotas marked this pull request as ready for review December 18, 2025 22:08
Copilot AI review requested due to automatic review settings December 18, 2025 22:08
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@jkotas
Copy link
Member

jkotas commented Dec 18, 2025

cc @dotnet/jit-contrib

This is causing a lot of noise in GC stress. Suppressing optimizations as a quick workaround.

@jkotas jkotas requested review from a team and agocke December 18, 2025 22:10
Copy link
Contributor

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 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 MethodImpl attribute with NoInlining | NoOptimization flags to prevent problematic compiler optimizations
  • Added explanatory comment linking to the tracked issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants