Skip to content

Fix thread-statics bootstrap recursion on WASM#131120

Draft
davidwrighton with Copilot wants to merge 1 commit into
mainfrom
copilot/next-blocker-spc-threads-on-wasm
Draft

Fix thread-statics bootstrap recursion on WASM#131120
davidwrighton with Copilot wants to merge 1 commit into
mainfrom
copilot/next-blocker-spc-threads-on-wasm

Conversation

Copilot AI commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

On WASM, GetThreadStaticsBase() computes the ThreadLocalData* by taking the address of DirectOnThreadLocalData.pNativeThread. On WASM, that field access goes through StaticsHelpers.GetNonGCThreadStaticBase, which itself calls GetThreadStaticsBase() — infinite recursion.

Fix: add a GetThreadStaticsBaseNative FCall (WASM-only) that returns &t_ThreadStatics directly from native, bypassing the managed thread-static lookup path.

  • Thread.CoreCLR.cs: #if TARGET_WASM path in GetThreadStaticsBase() calls GetThreadStaticsBaseNative() instead of the &pNativeThread pointer arithmetic; declares the FCall as [MethodImpl(InternalCall)].
  • comsynchronizable.h: declares GetThreadStaticsBaseNative FCDECL (WASM-only).
  • comsynchronizable.cpp: implements it returning (void*)&t_ThreadStatics; adds #include "threadstatics.h".
  • ecalllist.h: registers the FCall (WASM-only).

Extracted from main...AndyAyersMS:runtime:next-blocker-spc.

…tstrap recursion

Co-authored-by: davidwrighton <10779849+davidwrighton@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 21, 2026 00:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

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.

3 participants