Bug 2607 - Divide by zero exceptions are not being caught correctly in an embedded Mono runtime.
Summary: Divide by zero exceptions are not being caught correctly in an embedded Mono ...
Alias: None
Product: Runtime
Classification: Mono
Component: General ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2011-12-22 03:31 UTC by ghamrouni.iptech
Modified: 2017-07-07 18:27 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description ghamrouni.iptech 2011-12-22 03:31:18 UTC
We are using the embedded Mono runtime in a C++ application. 
Tested on Windows x86 and Mono 2.11 2.10 and 2.10.6

Scripts are executed by mono_runtime_invoke. When an unhanded exception occur in script-space it will be caught automatically :

MonoObject* exception = NULL;
MonoObject* returnObj = mono_runtime_invoke (m_method, m_objectInstance, NULL, &exception);
However, divide by zero exception is not caught and cause an exception in the C++ application !

Example :

int k = 0;
Console.WriteLine(1 / k);
Comment 1 Rodrigo Kumpera 2013-09-09 11:57:25 UTC
Please provide a minimal test case that shows this issue.

What might be happening is that the C++ host is hijacking the SEH handlers from mono which it depends to catch such errors.
Comment 2 Ludovic Henry 2017-07-07 18:27:57 UTC
If you can still reproduce with latest mono version, please feel free to reopen the bug. Thank you.