Hey guys, I think I've found a minor bug in either mcs or the runtime. I was writing a small app that has just has a Main() and a small while(true) loop, with a break condition inside it. However, when I compiled my app with mcs and ran it with mono, after breaking out of the while(true) loop my program kept running - it seems to just keep re-running Main(). Running with mint exits at the end of the first run, but with a "Trace/breakpoint trap" message.
However, if I change my Main() so that it returns int instead of void, and add a "return 0;" to the end, everything works as expected. I tried to isolate the problem with a small test case, and while it doesn't exhibit exactly the same behaviour, it still doesn't work as expected with Main() returning void - mint segfaults and mono returns the following error: ** (process:18686): WARNING (recursed) **: unhandled exception System.NullReferenceException: "A null value was found where an object instance was required" RESULT: -1 and then needs to be sent a ctrl-c. I'm running the mono CVS debs from http://www.atoker.com/mono/ as of yesterday on a Debian sid system. I've attached both my small test case and the original app (it's very small - all it does is iterate over the bytes of a text file looking for non-ascii chars) - I hope they're of some use. Thanks Leigh
using System;
public class BreakTest
{
public static void Main()
//public static int Main()
{
while(true)
{
Console.WriteLine("Breaking...");
break;
}
//return 0;
}
}
using System;
using System.IO;
public class NonAscii
{
public static void Main(string[] args)
//public static int Main(string[] args)
{
FileStream s = new FileStream(args[0], FileMode.Open, FileAccess.Read);
int line=0, ch=0;
int x=0;
while(true)
{
int c = s.ReadByte();
Console.WriteLine("char " + x + ": " + c);
if(c == -1) break;
if(c == '\n')
{
line++; ch=0;
} else {
if(c > 127)
{
Console.WriteLine("Non-ASCII char: line " +
line + ", char " + ch);
}
ch++;
}
x++;
}
//return 0;
}
}
signature.asc
Description: This is a digitally signed message part
