[Mono-list] Exceptions and error codes.

Piers Haken piersh@friskit.com
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
System.Runtime.InteropServices.COMException.

Piers.

> -----Original Message-----
> From: Paolo Molaro [mailto:lupus@ximian.com]=20
> Sent: Tuesday, March 25, 2003 4:30 AM
> To: mono-list@lists.ximian.com
> Subject: Re: [Mono-list] Exceptions and error codes.
>=20
>=20
> On 03/21/03 Thong (Tum) Nguyen wrote:
> > > You make some good arguments, but I think most of it is=20
> irrelevant=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.
> >=20
> >=20
> > Definitely.  I was more referring to our own class=20
> libraries (such as=20
> > GTK#).
>=20
> 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:
>=20
> 	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
>=20
> lupus
>=20
> --=20
> -----------------------------------------------------------------
> lupus@debian.org                                     debian/rules
> lupus@ximian.com                             Monkeys do it better
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com=20
> http://lists.ximian.com/mailman/listinfo/mono-list
>=20