[Mono-devel-list] RAPGO Proposal

Jonathan Pryor jonpryor at vt.edu
Tue Nov 30 07:48:15 EST 2004


<snip/>
> The other thing is that you can't catch C++ exceptions thrown in P/I 
> code by using a C-only approach.. Yes, I know that this is not supported 
> by mono, but somehow I thought adding this feature would be interesting. 
> Currently mono just gets terminated by the C runtime if a C++ exception 
> is thrown in native P/I code because no exception handler can be found..

In theory, you're possibly correct.  In practice, you're not. :-)

The problem is that on most platforms the C++ ABI isn't standardized.
Consequently, you can't link object code generated by different C++
compilers together.  Consequently, Mono could only handle C++ exceptions
generated by the same C++ compiler used to compile Mono.

On Linux, this isn't a particularly major issue (except when the C++ ABI
changes, such as in GCC 3.0, 3.1, 3.2...).  On other platforms which
have their own compiler in addition to GCC (SunOS, AIX, HP/UX, Windows,
all of which have their own vendor-supported C++ compilers), it is
highly unlikely that exceptions could be passed from unmanaged to
managed code.

Consider a Sun-generated C++ code which throws an exception being
handled by a GCC-compiled Mono runtime.  Mono would still die.  Ditto
for Windows SEH as used by MSVC and a GCC-compiled Mono runtime.

The only platforms where C++ and Mono exceptions could possibly work
portably is on platforms where the C++ ABI is standardized.  The only
such platform I'm aware of is IA64 (Itanic, er, Itanium), and Mono
doesn't have a JIT for that platform AFAIK.

Furthermore, if the platform *does* have a C++ ABI standard, then Mono
could just re-use the C++ exception structures, allowing C++ exceptions
to be properly handled by the Mono runtime.  A C++ compiler wouldn't be
necessary.

 - Jon





More information about the Mono-devel-list mailing list