[Mono-list] "finally" problem in mcs.exe

Jaroslaw Kowalski jarek@atm.com.pl
Wed, 22 May 2002 08:25:32 +0200 (CEST)

In a bug 24699/"finally being called twice" i described a problem where
"finally" handler is being called twice when an exception occurs.

It's not mentioned in the bug description, but the sample file was
compiled on Windows using csc.exe.

Today I've noticed that when I compile the program with mcs.exe on linux,
it behaves correctly under "mint" and "mono" but when compiled with
csc.exe there is still a problem with "mint" (mono was fixed and works

So: mcs + mono = OK, mcs + mint = OK, csc + mono = OK, csc + mint =

This suggests there's a bug in mcs compiler in the way finally handlers
are compiled. Also there's a problem with mint/mono that allows such
incorrectly-compiled program to run properly. Strange.

Are you aware of such a problem? If not, cosider this to be a new bug


Bug report from bugzilla:

Looks like the finally block is being called twice as in the example:
Seems to be critical.

   int c = 0;
    throw new Exception("Test exception");
   catch (Exception e)
    Console.WriteLine("Exception: {0}", e.Message);
    Console.WriteLine("Finally... {0}", c++);

Actual Results:
Exception: Test exception
Finally... 0
Finally... 1

Expected Results:
Exception: Test exception
Finally... 0
------- Additional Comments From Dietmar Maurer 2002-05-16 06:44 -------
fixed in mono, mint still have problems.