You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Regression in 16.10.0 release results in System.BadImageFormatException #11620
So, getService is type unit -> Service<#Data> - so being explicit with the return type via unit -> Service<Data> makes it a different type.
unit -> Service<#Data> tells us it found a free type variable due to #Data. This means getService is a forall type.
With it being captured in a closure, this might be the source of the issue. In release, this closure is probably getting erased.
I can confirm: This regression occurred when this was merged - #11349 .
However, the initial fix df4969b works fine. It was only until subsequent changes to the PR where we tried to simplify the local type functions does this regression occur.
cc @dsyme
@dsyme@TIHan Is the fix available in Visual Studio 16.11.2?
No, it isn't. It will be in VS2022. There is still discussion about whether it will qualify for a servicing fix. If you have a public-facing repro for this bug (especially in Release code) please document it below. Either way we would like to give good guidance about what code correction to make.
The thing that will help is lifting certain kinds of generic functions to no longer be inner-functions, or else type annotating them to be non-generic. This can be very subtle, which is why I want this serviced.
In release code this kind of lifting is often done automatically by the "lambda lifting" optimization. However there are restrictions on when that applies, which can make it even harder to determine.
@dsyme Agree.
In this codebase, we have heavy use of generics; lambda lifting is not always applicable.
It would be great if the fix goes through a service release.
We have added workarounds for a few cases, but still frequently encounter this defect in some pull requests (compiled in Release mode in CI).
We rolled back to Visual Studio 16.9 in some machines a while ago because of the defect.
It seems that we can't upgrade to 16.11 either.
I've got a wrong impression since the fix is included in 16.11 milestone https://github.com/dotnet/fsharp/milestone/41?closed=1.
The criteria for 16.11 tightened and we didn't fully analyse this in time for a deadline, partly due to change of staff. So a combination of factors. But my intuition is that this will need to go into a servicing release.
You can in theory workaround the problem by using .NET SDK before this was introduced, however the fsc.exe that ships with 16.10 and 16.11 has this problem as things currently stand.
You can in theory workaround the problem by using .NET SDK before this was introduced, however the fsc.exe that ships with 16.10 and 16.11 has this problem as things currently stand.
I tried that but couldn't make it work properly.
Moreover, we strive to keep up-to-date with Visual Studio versions; there are so many good things being added 😀.
Activity
cartermp commentedon Jun 3, 2021
Thanks for the repro, I can confirm it. I suspect we did regress somewhere here given that it still works in release mode. cc @TIHan
TIHan commentedon Jun 4, 2021
Testing this, in
Release, it does work however, I can't open the binary in ILSpy or ILDASM.I'm not sure yet why this is occurring.
TIHan commentedon Jun 4, 2021
peverifyjust tells us that it has bad headers.TIHan commentedon Jun 4, 2021
So,
getServiceis typeunit -> Service<#Data>- so being explicit with the return type viaunit -> Service<Data>makes it a different type.unit -> Service<#Data>tells us it found a free type variable due to#Data. This meansgetServiceis aforalltype.With it being captured in a closure, this might be the source of the issue. In release, this closure is probably getting erased.
TIHan commentedon Jun 4, 2021
I can confirm: This regression occurred when this was merged - #11349 .
However, the initial fix df4969b works fine. It was only until subsequent changes to the PR where we tried to simplify the local type functions does this regression occur.
cc @dsyme
dsyme commentedon Jul 7, 2021
This was fixed by #11755 .
@TIHan @jonsequitur Don't forget we may need to apply this as a servicing fix
dungpa commentedon Sep 1, 2021
@dsyme @TIHan Is the fix available in Visual Studio 16.11.2?
I saw a similar bug and upgrading to Visual Studio 16.11.2 didn't help.
I don't see this being mentioned in https://docs.microsoft.com/en-us/visualstudio/releases/2019/release-notes either.
dsyme commentedon Sep 1, 2021
No, it isn't. It will be in VS2022. There is still discussion about whether it will qualify for a servicing fix. If you have a public-facing repro for this bug (especially in Release code) please document it below. Either way we would like to give good guidance about what code correction to make.
dungpa commentedon Sep 1, 2021
I still experience this in Release mode.
In certain cases, inlining functions could help.
This is from some private code; I'll try to find an independent repro.
dsyme commentedon Sep 1, 2021
The thing that will help is lifting certain kinds of generic functions to no longer be inner-functions, or else type annotating them to be non-generic. This can be very subtle, which is why I want this serviced.
In release code this kind of lifting is often done automatically by the "lambda lifting" optimization. However there are restrictions on when that applies, which can make it even harder to determine.
dungpa commentedon Sep 1, 2021
@dsyme Agree.
In this codebase, we have heavy use of generics; lambda lifting is not always applicable.
It would be great if the fix goes through a service release.
We have added workarounds for a few cases, but still frequently encounter this defect in some pull requests (compiled in Release mode in CI).
We rolled back to Visual Studio 16.9 in some machines a while ago because of the defect.
It seems that we can't upgrade to 16.11 either.
I've got a wrong impression since the fix is included in
16.11milestone https://github.com/dotnet/fsharp/milestone/41?closed=1.dsyme commentedon Sep 1, 2021
The criteria for 16.11 tightened and we didn't fully analyse this in time for a deadline, partly due to change of staff. So a combination of factors. But my intuition is that this will need to go into a servicing release.
You can in theory workaround the problem by using .NET SDK before this was introduced, however the
fsc.exethat ships with 16.10 and 16.11 has this problem as things currently stand.dungpa commentedon Sep 1, 2021
I tried that but couldn't make it work properly.
Moreover, we strive to keep up-to-date with Visual Studio versions; there are so many good things being added 😀.