Skip to content

[wasm][coreclr] Do not use SetCleanupNeededForFinalizedThread#127562

Open
radekdoulik wants to merge 1 commit intodotnet:mainfrom
radekdoulik:clr-wasm-thread-finalizer
Open

[wasm][coreclr] Do not use SetCleanupNeededForFinalizedThread#127562
radekdoulik wants to merge 1 commit intodotnet:mainfrom
radekdoulik:clr-wasm-thread-finalizer

Conversation

@radekdoulik
Copy link
Copy Markdown
Member

@radekdoulik radekdoulik commented Apr 29, 2026

Note

PR description generated with Copilot assistance.

On wasm there is no finalizer thread. GC finalizers run inline on the main thread, causing SetCleanupNeededForFinalizedThread to hit the IsFinalizerThread() assert when a Thread object is finalized.

The call to CleanupFinalizedThreads is not reached anyway because HaveExtraWorkForFinalizer returns false on wasm.

Also enable System.Threading.Thread tests on browser/CoreCLR.

This avoids reaching assert in SetCleanupNeededForFinalizedThread as
we don't have finalizer thread.

CleanupFinalizedThreads is not reached anyway, because
HaveExtraWorkForFinalizer is returning false on wasm. Thus
DoExtraWorkForFinalizer is not called and so is not calling
SetCleanupNeededForFinalizedThread either.

Enable System.Threading.Thread tests
Copilot AI review requested due to automatic review settings April 29, 2026 14:07
@radekdoulik radekdoulik added this to the Future milestone Apr 29, 2026
@radekdoulik radekdoulik added arch-wasm WebAssembly architecture area-VM-coreclr labels Apr 29, 2026
@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.

}

thread->SetThreadState(Thread::TS_Finalized);
#ifndef TARGET_WASM
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should use FEATURE_MULTITHREADING

Copy link
Copy Markdown
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 addresses a CoreCLR/WASM mismatch around Thread finalization: WASM doesn’t have a dedicated finalizer thread, so running Thread finalizers inline can trip IsFinalizerThread()-based assertions. It also re-enables System.Threading.Thread library tests for browser/CoreCLR by removing the project exclusion.

Changes:

  • Guard Thread::SetCleanupNeededForFinalizedThread() out on TARGET_WASM to avoid the IsFinalizerThread() assert during Thread finalization.
  • Re-enable System.Threading.Thread.Tests on browser/CoreCLR by removing its exclusion from src/libraries/tests.proj.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/libraries/tests.proj Removes the browser/CoreCLR exclusion for System.Threading.Thread.Tests so the test project runs again.
src/coreclr/vm/comsynchronizable.cpp Skips SetCleanupNeededForFinalizedThread() on WASM during ThreadNative::Finalize to avoid finalizer-thread assertions.

}

thread->SetThreadState(Thread::TS_Finalized);
#ifndef TARGET_WASM
Comment thread src/libraries/tests.proj
@@ -185,8 +185,6 @@

<!-- https://github.com/dotnet/runtime/issues/125495 - These tests are disabled on browser/CoreCLR because of crashes and test failures. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-VM-coreclr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants