[Mono-dev] NullReferenceException thrown inside catch
Robert Jordan
robertj at gmx.net
Fri Aug 25 10:04:09 EDT 2006
Janne Rantala wrote:
>> The Windows port seems to use SEH. Maybe a SEH handler
>> could be able to catch the exception:
>>
>> #include <windows.h>
>>
>> MonoException *ex;
>>
>> __try {
>> mono_runtime_invoke ( ..., &ex);
>> }
>> __except (EXCEPTION_EXECUTE_HANDLER) {
>>
>> /* simulate a NRE */
>> ex = mono_get_exception_null_reference ();
>> }
>>
>> if (ex != NULL) {
>> handle the exception
>> }
>>
>> The code is for VC++ in C mode (not C++).
>>
>> Robert
>>
>
> Hi,
>
> That works very well, thanks. It would be nice if both Linux and
> Windows version would work the same way though.
Please file a bug, because the SEH handler above only cures the
symptoms partially.
It seems that Mono's SIGSEGV handler doesn't get installed
at all, when mono-1.dll is LoadLibrary'ed from another DLL.
W/out this handler every true NRE is uncatchable.
This could lead to nasty bugs, because some library code
might rely on catching those NREs.
Robert
More information about the Mono-devel-list
mailing list