mathnet / mathnet-numerics

Math.NET Numerics
http://numerics.mathdotnet.com
MIT License
3.47k stars 893 forks source link

.Net Native Internal Compiler Error NUTC3028 on DenseColumnMajorMatrixStorage.Find2Unchecked #361

Open mtaron opened 8 years ago

mtaron commented 8 years ago

I am attempting to use MathNet.Numerics in a Universal Windows application. It works fine when I build and run debug, but has the following error when I try to build release. (It is expected that release and debug build can behave differently since release builds use .Net Native: https://msdn.microsoft.com/en-us/vstudio/dotnetnative.aspx). Could be a .Net Native bug, but thought you'd want to know.

NUTC3028:Internal Compiler Error: Method 'instance System.Tuple4<System.Int32, System.Int32, T, TOther> MathNet.Numerics.LinearAlgebra.Storage.DenseColumnMajorMatrixStorage1.Find2Unchecked(MathNet.Numerics.LinearAlgebra.Storage.MatrixStorage1<TOther>, System.Func3<T, TOther, System.Boolean>, MathNet.Numerics.LinearAlgebra.Zeros)' on type 'MathNet.Numerics.LinearAlgebra.Storage.DenseColumnMajorMatrixStorage1<T>' from assembly 'MathNet.Numerics' tried to implicitly override a method with weaker type parameter constraints while loading type 'MathNet.Numerics.LinearAlgebra.Storage.DenseColumnMajorMatrixStorage1'. while computing compilation roots.

cdrnet commented 8 years ago

Thanks for reporting this, I can reproduce it locally and get the same error. The compiler did run for longer than an hour to get to this point though - did you have a similar experience or am I doing something wrong?

cdrnet commented 8 years ago

For reference: StackOverflow: .Net Native Internal Compiler Error NUTC3028 when overriding mixed generic methods

mtaron commented 8 years ago

Yeah, I am seeing the super slow performance as well. I let the build go overnight. :\

MattWhilden commented 8 years ago

As per my comment in the StackOverflow issue, I'd love to take a look at. Feel free to send information to the mail address dontnetnative@microsoft.com. It's a bit easier for our internal tracking if you come in that way. :-)

MattWhilden commented 8 years ago

I have repro'd this issue and we're investigating. It's getting stuck in a piece of the compiler that is trying to work out all of the various generic instantiations that you'll eventually want. Will report back in a bit with some more info.

MattWhilden commented 8 years ago

So the error is a bug we'll be fixing for Update 2 (spring-ish?). This is a typesystem bug in the nutc component of ILC. We don’t properly flow the generic method parameter (and presumably the generic type parameter) when performing verification that the virtual method is properly structured. The error message is correct, assuming the check in the type system was correct, but unfortunately, the type system check is incorrect for generic type parameters with constraints that are instantiated over the method's type parameters.

Still investigating the absurd build times.

cdrnet commented 8 years ago

Thanks a lot for looking into this and for the analysis!

MattWhilden commented 8 years ago

Yep. Feel free to tag me if you see other things that are weird (here or in other repos). These issues aren't always easy to get proper testing for and we're super interested in getting them chased down.

MattWhilden commented 8 years ago

So a bit of an update. The compile time issues should be resolved in Update 2. We have replaced on of our cycle detection algorithms with an O(n) implementation. This takes the compile time for the blank app+this library from 1hr+ to 37 seconds on my machine.

cdrnet commented 8 years ago

That's quite an improvement :) I'm looking forward to give this another spin with Update 2. Thanks again!

ebroglio commented 8 years ago

Any updates on this? Is there a workaround?

MattWhilden commented 8 years ago

The compile time issue will be corrected in the next set of RTM tools for .NET Native. Depending on your shipping schedule and other constraints we may be able to help out. Please send a mail to dotnetnative@microsoft.com

MattWhilden commented 8 years ago

.NET Native 1.3 is now live and should have all the fixes eluded to above. Do let us know if there are any other troubles/issues. Happy to help.

ntindle commented 6 years ago

Is this issue still open?