[Mono-list] Exceptions and error codes.
Tue, 25 Mar 2003 08:05:57 -0800
Managed code on the MS CLR doesn't use SEH internally, but the interop
services rethrow System.Runtime.InteropServices.SEHException. The Win32
C++ ABI uses SEH. Similarly, COM error codes are rethrown as
> -----Original Message-----
> From: Paolo Molaro [mailto:email@example.com]=20
> Sent: Tuesday, March 25, 2003 4:30 AM
> To: firstname.lastname@example.org
> Subject: Re: [Mono-list] Exceptions and error codes.
> On 03/21/03 Thong (Tum) Nguyen wrote:
> > > You make some good arguments, but I think most of it is=20
> > > since, in order to remain compatible with .NET, Mono must=20
> behave the=20
> > > same way with respect to returning (or not) exceptions. The MSDN=20
> > > docs describe exactly what exceptions/return codes File.Exists and
> > File.Open
> > > should return, Mono should do the same (unless the docs are in=20
> > > error).
> > A
> > > lot of work has already been done on this. You'll notice=20
> that many=20
> > > of the test cases test whether or not the correct=20
> exception is being=20
> > > returned.
> > Definitely. I was more referring to our own class=20
> libraries (such as=20
> > GTK#).
> I just want to add another data point to the ones already=20
> explained about the use of error codes or exceptions,=20
> especially as it relates to
> Gtk+, but this also applies to other libraries that are P/invoked from
> the CLR.
> C code has no notions of exceptions and of the way exception=20
> handling can unwind the stack (yes, on windows people use SEH=20
> in C code, but it's non-standard and I don't even know if the=20
> MS CLR deals with SEH in C code). So what may happen is:
> C# code with a try block=20
> -> Gtk+ code (takes a lock and calls a delegate)
> -> C# code that trows an exception
> -> exceptions handling triggers and gets the stack back=20
> to the try block
> -> next time Gtk+ is called again and it needs the lock (that
> could be not unlocked by the exception code, since it's not
> aware of it) you get a nice deadlock=09
> email@example.com debian/rules
> firstname.lastname@example.org Monkeys do it better
> Mono-list maillist - Monoemail@example.com=20