Skip to content

Conversation

MichalStrehovsky
Copy link
Member

Fixes #116089.

The method accesses shared static state, locking is needed.

Cc @dotnet/ilc-contrib

Fixes dotnet#116089.

The method accesses shared static state, locking is needed.
@Copilot Copilot AI review requested due to automatic review settings September 2, 2025 13:38
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 adds thread safety to the GetNewThunksBlock method by introducing a lock to protect access to shared static state. The issue was that multiple threads could concurrently access and modify the static fields s_currentlyMappedThunkBlocks and s_currentlyMappedThunkBlocksIndex without synchronization, leading to potential race conditions.

Key changes:

  • Adds a static Lock field for synchronization
  • Wraps the GetNewThunksBlock method body with lock acquisition using the new Lock.Scope pattern
  • Imports the System.Threading namespace to support the locking functionality

@MichalStrehovsky MichalStrehovsky merged commit e4df9f3 into dotnet:main Sep 3, 2025
93 of 96 checks passed
@MichalStrehovsky MichalStrehovsky deleted the fix116089 branch September 3, 2025 13:13
filipnavara pushed a commit to filipnavara/runtime that referenced this pull request Sep 5, 2025
Fixes dotnet#116089.

The method accesses shared static state, locking is needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Race condition creating thunkpools
3 participants