Skip to content

[API Proposal]: Track Exceptions in flight (information about the state that existed for the thread when the exception occurred) #98878

@Yun-Ting

Description

@Yun-Ting

Background and motivation

Currently, Marshal.GetExceptionPointers is not supported in native AOT.

See the environment control flag in runtime:

public static bool IsMarshalGetExceptionPointersSupported => !IsMonoRuntime && !IsNativeAot;

See open-telemetry/opentelemetry-dotnet#5374 (comment) on how this could be achieved.

API Proposal

Currently, getting in-flight exception is not supported in native AOT:

FCIMPL0(EXCEPTION_POINTERS*, ExceptionNative::GetExceptionPointers)

I propose to enable this feature in native AOT:

FCIMPL0(EXCEPTION_POINTERS*, ExceptionNative::GetExceptionPointers)
{
    FCALL_CONTRACT;

    EXCEPTION_POINTERS* retVal = NULL;

    Thread *pThread = GetThread();
    if (pThread->IsExceptionInProgress())
    {
        retVal = pThread->GetExceptionState()->GetExceptionPointers();
    }

    return retVal;
}
FCIMPLEND

API Usage

See this issue: open-telemetry/opentelemetry-dotnet#5358

Alternative Designs

No response

Risks

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-NativeAOT-coreclrneeds-author-actionAn issue or pull request that requires more info or actions from the author.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions