dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.27k stars 4.73k forks source link

Error in lsra.cpp, Line:2651 #4010

Closed evolvedmicrobe closed 4 years ago

evolvedmicrobe commented 9 years ago

The following program throws an exception when run on Ubuntu with coreclr. I attempted to compile and run it after I compiled the hello world example here: https://github.com/dotnet/coreclr/wiki/Building-and-Running-CoreCLR-on-Linux.

Program code is:

using System;    

namespace Test 
{
    public class CommandLine
    {
        [STAThread]
        public static void  Main(System.String[] args)
        {
             measure(500, 2.0);
        }    

        public static double measure(int N, double mintime)
        {
            int i =0;   
            long cycles = 1;
            Stopwatch Q = new Stopwatch();
            while (true)
            {
                i++;
                Q.stop();
                if (Q.read() >= mintime)
                    break;    

                cycles *= 2;
            }
            return 3.0;
        }
    }
    public class Stopwatch
    {
        private bool running;
        private double last_time;
        private double total;

        public static double seconds()
        {
            return (System.DateTime.Now.Ticks * 1.0E-7);
        }

        public virtual void  reset()
        {
            running = false;
            last_time = 0.0;
            total = 0.0;
        }

        public Stopwatch()
        {
            reset();
        }   

        public virtual void  start()
        {
            if (!running)
            {
                running = true;
                total = 0.0;
                last_time = seconds();
            }
        }

        public virtual double stop()
        {
            if (running)
            {
                total += seconds() - last_time;
                running = false;
            }
            return total;
        }

        public virtual double read()
        {
            if (running)
            {
                total += seconds() - last_time;
                last_time = seconds();
            }
            return total;
        }
    }
}

Compiled as:

#!/bin/sh 
R_DIR=/home/UNIXHOME/coreclr/runtime
mcs -optimize  -noconfig -nostdlib -r:$R_DIR/mscorlib.dll -r:$R_DIR/System.Runtime.dll -r:$R_DIR/System.Console.dll Test.cs -out:Test.exe

Ran it as:

~/coreclr/runtime/corerun Test.exe

And wound up with error:

Assert failure(PID 17060 [0x000042a4], Thread: -181622304 [0xf52ca9e0]): Assertion failed 'compiler->opts.compDbgEnC' in 'Test.CommandLine:measure(int,double):double' (IL size 59)    

    File: /home/UNIXHOME/git/coreclr/src/jit/lsra.cpp, Line: 2651 Image:
/home/UNIXHOME/coreclr/runtime/corerun
**** MessageBox invoked, title 'corerun - Assert Failure (PID 17060, Thread -181622304/f52ca9e0)        ' ****
  Assertion failed 'compiler->opts.compDbgEnC' in 'Test.CommandLine:measure(int,double):double' (IL size 59)    

/home/UNIXHOME/git/coreclr/src/jit/lsra.cpp, Line: 2651    

Image:
/home/UNIXHOME/coreclr/runtime/corerun    

********
ellismg commented 9 years ago

@LLITCHEV might be interested in this. What commit was HEAD pointing to when you built coreclr?

evolvedmicrobe commented 9 years ago

Thanks! Head was at:

commit 92648f4b69815d52eba5f777cfa1918724afe6df Merge: 828768d 100fdc1 Author: Jan Kotas jkotas@microsoft.com Date: Thu Feb 26 10:29:52 2015 -0800

Merge pull request dotnet/coreclr#348 from kangaroo/issue-222

[OSX] Resolve all compiler warnings in the PAL
LLITCHEV commented 9 years ago

This should be fixed with the following pull request. https://github.com/dotnet/coreclr/pull/335

It looks like the code sample above has an infinite loop. The assertion is not happening more, though.

evolvedmicrobe commented 9 years ago

Yep, error gone, thanks! The full program still can't run due to what appears to be the issue described in dotnet/runtime#3941 , but thanks for the progress on linux!