Skip to content

Conversation

@pavelsavara
Copy link
Member

@pavelsavara pavelsavara commented Jan 26, 2026

Contributes to #114096

@pavelsavara pavelsavara added this to the 11.0.0 milestone Jan 26, 2026
@pavelsavara pavelsavara self-assigned this Jan 26, 2026
@pavelsavara pavelsavara added arch-wasm WebAssembly architecture area-GC-coreclr os-browser Browser variant of arch-wasm labels Jan 26, 2026
@dotnet-policy-service
Copy link
Contributor

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

@pavelsavara
Copy link
Member Author

pavelsavara commented Jan 28, 2026

This can't be merged right now because enabling finalizer uncovered some memory corruption.

Edit: I commented out the effective piece of code and added TODO-WASM #123712

So that I could merge the code and work with it further on other PRs.

@pavelsavara pavelsavara added the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Jan 28, 2026
Copilot AI review requested due to automatic review settings February 1, 2026 15:05
@pavelsavara pavelsavara removed the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Feb 1, 2026
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

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

@pavelsavara
Copy link
Member Author

THROWS called in a NOTHROW region.

Log

Assert failure(PID 3368 [0x00000d28], Thread: 1144 [0x0478]): CONTRACT VIOLATION by ManagedThreadBase::KickOff at "D:\a\_work\1\s\src\coreclr\vm\threads.cpp":6033

THROWS called in a NOTHROW region.

                        CONTRACT in ManagedThreadBase::KickOff at "D:\a\_work\1\s\src\coreclr\vm\threads.cpp":6033
VIOLATED-->  CONTRACT in FinalizerThread::FinalizerThreadStart at "D:\a\_work\1\s\src\coreclr\vm\finalizerthread.cpp":562

CORECLR! BaseContract::DoChecks + 0x14A (0x6f3bfcfa)
CORECLR! EEContract::DoChecks + 0x58 (0x6f8e98e8)
CORECLR! ManagedThreadBase::KickOff + 0xBA (0x6f80844a)
CORECLR! FinalizerThread::FinalizerThreadStart + 0x22C (0x6f913c6c)
KERNEL32! BaseThreadInitThunk + 0x24 (0x74ce62c4)
NTDLL! RtlSubscribeWnfStateChangeNotification + 0x439 (0x77de0989)
NTDLL! RtlSubscribeWnfStateChangeNotification + 0x404 (0x77de0954)
    File: D:\a\_work\1\s\src\coreclr\vm\threads.cpp:6033
    Image: C:\h\w\A7630989\p\dotnet.exe

@pavelsavara
Copy link
Member Author

I added NOTHROW contract into FinalizerThread::FinalizerThreadStart because I thought that UNINSTALL_UNHANDLED_MANAGED_EXCEPTION_TRAP would always catch any exception.

Looking at the UNINSTALL_UNHANDLED_MANAGED_EXCEPTION_TRAP I see that it catches only some exceptions.
catch (PAL_SEHException& ex) and only on Unix.

The failure above is from Windows.

Is my new contract too strict ? Or we need to catch something on Windows too ?

@janvorli
Copy link
Member

janvorli commented Feb 2, 2026

Right, that macro works only on Unix, because on Windows, the OS itself ensures that the exception is reported as unhandled. On Unix, without that macro, we would get an unhandled PAL_SEHException C++ exception instead, which is not desired.
So for Windows the NOTHROW contract is not correct here. But for Unix, it is actually correct, as all managed exceptions (they are represented by the PAL_SEHException) would be caught there. So we could possibly use the NOTHROW contract for Unix only. Alternatively, we could use the CONTRACT_VIOLATION(ThrowsViolation) in your code that calls this method.

Copilot AI review requested due to automatic review settings February 2, 2026 14:34
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

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

@pavelsavara
Copy link
Member Author

/ba-g known issues
#123796
#123912

@pavelsavara pavelsavara merged commit ea33ea7 into dotnet:main Feb 2, 2026
153 of 160 checks passed
@pavelsavara pavelsavara deleted the browser_finalizer branch February 2, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-GC-coreclr os-browser Browser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants