[Mono-list] Problem with while loop and Main returning void
Dwivedi , Ajay Kumar
Wed, 3 Jul 2002 09:20:08 +0100
Surely a bug in both mcs and runtime.
Firstly mcs did not generate the ret statement. The monodis of
the break.exe shows:
IL_000f: br IL_0019
but there is no instruction at IL_0019. Looks like the ret instruction
is not generated although it is assumed to be there.
The PE file is invalid since "fall thru end of the method" is
not allowed. This is the error reported by PEVerify on a custom assembled
exe where ret statement is replaced by nop.
The runtime is also in error since it should throw an exception
which it finds the branch instruction is asking it to transfer control
to nonexisting location.
> -----Original Message-----
> From: Leigh Dyer [mailto:email@example.com]
> Sent: Wednesday, July 03, 2002 12:00 PM
> To: firstname.lastname@example.org
> Subject: [Mono-list] Problem with while loop and Main returning void
> 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.