Skip to content

cDAC: Loader_1.GetModuleHandles inverts the IncludeAvailableToProfilers check #135469

Closed

Description

@pcshrosbree

Loader_1.GetModuleHandles (src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/Loader_1.cs, line 98) has:

if ((assembly.NotifyFlags & ASSEMBLY_NOTIFYFLAGS_PROFILER_NOTIFIED) != 0 && !iterationFlags.HasFlag(AssemblyIterationFlags.IncludeAvailableToProfilers))
{
    // The assembly has reached the state at which we would notify profilers,
    // and we're supposed to include such assemblies in the enumeration. So
    // don't reject it ...
}

The native iterator it mirrors, AppDomain::AssemblyIterator::Next_Unlocked (src/coreclr/vm/appdomain.cpp, line 3807), tests the flag the other way round:

if (pAssembly->IsAvailableToProfilers() &&
    (m_assemblyIterationFlags & kIncludeAvailableToProfilers))

So in the cDAC, a profiler-notified assembly skips the loaded/loading checks when the caller did not pass IncludeAvailableToProfilers, and is filtered normally when it did. No cDAC caller passes that flag today, so only the first half is reachable: for every current caller, notified assemblies bypass the IncludeLoaded/IncludeLoading filter. Whether that changes a result depends on whether a notified assembly can still be loading at that point. A future caller that passes IncludeAvailableToProfilers alone would get no notified assemblies.

The pseudocode in docs/design/datacontracts/Loader.md (around line 329) has the same inversion.

Found by reading the code, not from a failing test; main at 98a24e3.

Activity

  1. dotnet-policy-service commented on Oct 9, 2026

    @dotnet-policy-service
    Contributor

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

  2. dotnet-policy-service commented on Oct 9, 2026

    @dotnet-policy-service
    Contributor

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

  3. added a commit that references this issue on Oct 12, 2026
    0d21247
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions