runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Ildasm creates IL that ilasm cannot assemble

Open SamPlusPlus opened this issue 6 years ago • 5 comments

Description

Apologies in advance if this is not the correct place. I am also not sure if the issue is in ildsam or ilasm. I am far from an expert when it gets to IL code. so I will do my best to explain the issue here. A full repo is attached and I have tried to make it as small as possible

I am attempting to use AzurePipeline's latest windows build a machine which has NETFX 4.8 installed on it. I am upgrading from a build machine that had NETFX 4.6.1 installed. The build script does some ILdasm, manipulates the DLL and then calls ilasm to reconstruct.

With NET 4.6.1's version of ILdasm it works just fine. When attempting to use NET 4.8 I receive the following error.

error : syntax error at token '-' in: IL_003c: ldc.r8 -nan(ind)

I was able to identify the classes that were causing the issue. So I created a small dll containing only 2 small files a class and an interface.

using System;

namespace Test
{
    internal class FormulaAverage : IFormula
    {
        public object Calc(object[] data)
        {
            int count = 0;
            double sum = 0d;
            foreach (object obj in data)
            {
                try
                {
                    double value = Convert.ToDouble(obj);
                    sum = sum + value;
                    count++;
                }
                catch (FormatException e)
                {
                    //do nothing
                }
            }
            return (count > 0) ? sum/count : double.NaN;
        }
    }
}

namespace Test
{
    internal interface IFormula
    {
        object Calc(object[] data);
    }
}

I was able to diff the IL between the two runs of the tools.

image

Configuration

Running the latest version of Windows 10 on a x64 bit processer

To cause the error I used C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\ildasm.exe in conjunction with C:\Windows\Microsoft.NET\Framework\v4.0.30319\ilasm.exe

It works if I use C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\ildasm.exe in conjunction with C:\Windows\Microsoft.NET\Framework\v4.0.30319\ilasm.exe

Regression?

Yes it worked with

image

Other information

Attached is a full simplified reproduction case, with a simplified input dll and scripts to call the working and broken configuration. However, it will depend on having both configurations installed. ildsm-repro.zip

SamPlusPlus avatar May 31 '20 02:05 SamPlusPlus

I couldn't figure out the best area label to add to this issue. Please help me learn by adding exactly one area label.

Dotnet-GitSync-Bot avatar May 31 '20 02:05 Dotnet-GitSync-Bot

I couldn't figure out the best area label to add to this issue. Please help me learn by adding exactly one area label.

I am not sure how to add the area label, but if I had to guess it would be area-ILTools-coreclr @BruceForstall @dotnet/jit-contrib

SamPlusPlus avatar May 31 '20 02:05 SamPlusPlus

This is a duplicate of the regression documented in https://github.com/dotnet/runtime/issues/36599.

AaronRobinsonMSFT avatar Jun 01 '20 19:06 AaronRobinsonMSFT

This is a issue in .NET Framework. .NET Framework issues should be reported via VS Developer Community Portal (https://github.com/dotnet/core#getting-help).

jkotas avatar Jun 07 '20 12:06 jkotas

@SamPlusPlus Could you please open this issue via VS Developer Community Portal?

jkotas avatar Jun 07 '20 13:06 jkotas