Skip to content

Calling a CsWinRT NAOT dll's DllCanUnloadNow export triggers CFG failure #105330

@jevansaks

Description

@jevansaks

Description

Using ControlFlowGuard when creating a native dll that uses CsWinRT (which generates the DllGetActivationFactory and DllCanUnloadNow native exports) and publishing that as AOT creates a dll with DllCanUnloadNow not in the icall table. This causes an external caller of DllCanUnloadNow (in my case, combase.dll since this is part of implementing the WinRT contract) to failfast with FAST_FAIL_GUARD_ICALL_CHECK_FAILURE.

Reproduction Steps

Minimal repro project with repro steps in readme:

https://github.com/jevansaks/NAOTControlFlowGuardRepro/tree/main

Expected behavior

All exports of the dll should be in the CFG table since they're designed to be called virtually.

Actual behavior

DllGetActivationFactory export is in the CFG table but DllCanUnloadNow is not.

Regression?

I don't know. Probably not a regression.

Known Workarounds

No response

Configuration

.NET 8, running on Windows 11, compiling for windows-x64 native. I didn't try any other windows native targets.

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-NativeAOT-coreclrin-prThere is an active PR which will close this issue when it is merged

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions