Skip to content

Friend assemblies ("InternalsVisibleTo") can leak via automatic inlining cause runtime error #7422

Open
@manofstick

Description

@manofstick

Assembly A exposed it's internal to Assembly B via the InternalsVisibleTo attribute. Assembly B provides a simple method to Assembly C, but because it's a simple method, it is inlined by the f# compiler into Assembly C. This results in Runtime error.

Expected behavior

The FSharp compiler shouldn't inline methods that have calls to methods that have been exposed via InternalsVisibleTo.

Actual behavior

Runtime error.

Known workarounds

As per #5178, the use of [<MethodImpl(MethodImplOptions.NoInlining)>] stops the f# compiler from inling the method, but has the side effect that the JIT also stops inlining the call.

Related information

C:> fsc.exe
Microsoft (R) F# Compiler version 10.4.0 for F# 4.6
Copyright (c) Microsoft Corporation. All Rights Reserved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.

    Type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions