Skip to content

Conversation

@am11
Copy link
Member

@am11 am11 commented Jan 8, 2026

Fixes #116375.

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jan 8, 2026
@dotnet-policy-service
Copy link
Contributor

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

@am11 am11 force-pushed the feature/il_throw_PUSH_COOP_PINVOKE_FRAME branch from 1a243a6 to 00c4f6a Compare January 8, 2026 22:39
@am11 am11 force-pushed the feature/il_throw_PUSH_COOP_PINVOKE_FRAME branch from b8782d2 to 0d677dd Compare January 8, 2026 22:41
@am11 am11 force-pushed the feature/il_throw_PUSH_COOP_PINVOKE_FRAME branch from 0d677dd to 5359b4c Compare January 8, 2026 22:42
{
// Create a NullReferenceException and throw it with the correct context
EEException ex(kNullReferenceException);
oref = ex.CreateThrowable();
Copy link
Member

@jkotas jkotas Jan 9, 2026

Choose a reason for hiding this comment

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

If CreateThrowable throws OutOfMemoryException here, is it going to be handled gracefully?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the original DispatchManagedException(kNullReferenceException) overload does the same thing internally; it calls CreateThrowable() which can throw OOM. So the behavior is unchanged. The exception frame (SoftwareExceptionFrame) is already set up and we're inside FC_CAN_TRIGGER_GC(), so if OOM is thrown, it will be dispatched normally through the existing exception handling machinery.

Copy link
Member

Choose a reason for hiding this comment

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

As a test, I have added new int[(size_t)1000000000 * (size_t)1000000000]; here and run the following test (on Windows):

using System;

try {
    throw null;
}
catch (OutOfMemoryException) {
}

Expected behavior: The exception should be handled by the catch,
Actual behavior: The test failed with Unhandled exception. System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.)

I think we are missing one of those macros that flips between C++ and managed exceptions here. @janvorli What's the right macro to use here?

(It is possible that this is broken in main currently - I have not tested that.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. I was primarily testing in CI and observed failures on both linux-arm64 and x64. With arm64 now fixed by updating the offset, I’ll look into what adjustments are needed for x64. In the meantime, I’ve reverted this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-VM-coreclr community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bring IL_{Throw,Rethrow,ThrowExact} to PUSH_COOP_PINVOKE_FRAME plan

2 participants