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 AI review requested due to automatic review settings September 2, 2025 13:38
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 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

…e/ThunkPool.cs

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
@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.
@github-actions github-actions bot locked and limited conversation to collaborators Oct 4, 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.

Race condition creating thunkpools

3 participants