dotnet / dotnet/fsharp

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

Open
#7,422 5 comments 0 reactions 0 assignees View on GitHub
Area-Compiler-Checking Area-Compiler-Checking-Accessibility Area-Compiler-Optimization Bug Impact-Medium
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

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 `[]` 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.