[Mono-dev] crashes in glib hangs (not exits) program

Jonathan Pryor jonpryor at vt.edu
Mon Apr 21 13:30:35 EDT 2008


On Mon, 2008-04-21 at 16:34 +0100, Alan McGovern wrote:
> >  For some reason, catching the "unmanaged exception" has the correct
> >  behaviour even though it could be just a side effect. Zoltan pointed
> >  out that unmanaged exceptions are not converted to exceptions in mono
> >  even though the windows side seem to do it and recomment using
> >  AppDomain.UnhandleException to log the crash before terminating. I am
> >  not sure how they do it ... since the unmanaged exception could have
> >  corrupted basic data structures so much that even the logging might
> >  fail.
> 
> Could MS.NET be using structured exception handling?
> 
> http://www.microsoft.com/msj/0197/exception/exception.aspx

Yes, .NET uses SEH around all P/Invoke calls (just as RPC/DCOM/etc. all
use SEH around all remote calls, etc.).

Furthermore, Win32 doesn't have signals, it uses SEH for everything
(e.g. instead of SIGSEGV, there's an SEH exception that's generated
instead).

So all .NET has to do is translate an unmanaged SEH exception into a
managed exception type, and it's Good To Go.

Should the process get sufficiently corrupted that SEH no longer works,
the process is unconditionally aborted (forget where I read that...).

On the whole, Win32 seems far more "exception-ready" than Unix, largely
because it was designed around the concept of exceptions from the
beginning (and because Win32 exceptions aren't a complete match to Unix
signals, iirc exceptions aren't used for SIGHUP, SIGINT, etc...).

 - Jon




More information about the Mono-devel-list mailing list