Skip to content

CoreCLR's debug/checked last error trashing leaks in non-P/Invoke scenarios #59721

Open
@jkoritzinsky

Description

@jkoritzinsky

CoreCLR has a macro named TRASH_LASTERROR in utilcode that is used to make it easier to detect when the "last system error code" is not preserved in P/Invoke scenarios.

However, it leaks out in a number of non-P/Invoke scenarios, which impacts some of the DllImportGenerator tests that use DNNE to make the logic of the native side of the generated code tests implemented in managed code. This causes test failures with a Debug/Checked runtime since the expected error code is not set since CoreCLR sets an error code value and leaves it set.

For example, it leaks out of coreclr_create_delegate's calls to StringToUnicode, as well as ComponentActivator's calls to Marshal.PtrToStringAuto.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions