Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Fix #320 - InvalidProgramException on .NET < 4.5.2 on x64 #687

Merged
merged 1 commit into from Feb 7, 2015

Conversation

nguerrera
Copy link
Contributor

In .NET 4.5 and .NET 4.5.1 on x64, the JIT would attempt to inline a
particular generic method, which would cause it to bail with an
InvalidProgramException.

Workaround the issue by applying MethodImplOptions.NoInlining to the
method. There is no perf loss because the whole purpose of this method
is to throw in the failure case and it is factored out precisely to
help the inlining of its callers.

The JIT bug has already been fixed in .NET 4.5.2, but we support
immutable collections on .NET 4.5 and .NET 4.5.1 as well, which is
why we must workaround the issue.

@nguerrera nguerrera changed the title Fix #320 - InvalidProgramException on .NET 4.5 x64 Fix #320 - InvalidProgramException on .NET < 4.5.2 on x64 Feb 7, 2015
@nguerrera
Copy link
Contributor Author

@nguerrera
Copy link
Contributor Author

Note about testing: simply running our unit tests with a release build on .NET 4.5 RTM x64 causes 79 failures due to this issue. However, our infrastructure is not setup to run in that configuration at the moment.

In .NET 4.5 and .NET 4.5.1 on x64, the JIT would attempt to inline a
particular generic method, which would cause it to bail with an
InvalidProgramException.

Workaround the issue by applying MethodImplOptions.NoInlining to the
method. There is no perf loss because the whole purpose of this method
is to throw in the failure case and it is factored out precisely to
help the inlining of its callers.

The JIT bug has already been fixed in .NET 4.5.2, but we support
immutable collections on .NET 4.5 and .NET 4.5.1 as well, which is
why we must workaround the issue.
@ellismg
Copy link
Contributor

ellismg commented Feb 7, 2015

LGTM. Sounds like a fun one to track down :-).

@nguerrera
Copy link
Contributor Author

Thanks, @ellismg. Yes, fun. :)

nguerrera added a commit that referenced this pull request Feb 7, 2015
Fix #320 - InvalidProgramException on .NET < 4.5.2 on x64
@nguerrera nguerrera merged commit 800a8af into dotnet:v1.0 Feb 7, 2015
@nguerrera nguerrera deleted the workaround-320 branch February 7, 2015 22:59
@stephentoub
Copy link
Member

LGTM. Nice work tracking it down.

@pharring
Copy link

pharring commented Feb 8, 2015

@nguerrera OK, agreed. Usage of typeof(T) is rare enough.

@karelz karelz modified the milestone: 1.0.0-rtm Dec 3, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
6 participants