Bug 45370 - Exception occurring during exception filter evaluation is not handled
Summary: Exception occurring during exception filter evaluation is not handled
Status: NEW
Alias: None
Product: Runtime
Classification: Mono
Component: JIT (show other bugs)
Version: master
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-10-13 16:37 UTC by Jonathan Chambers
Modified: 2016-10-13 16:38 UTC (History)
2 users (show)

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


Attachments

Description Jonathan Chambers 2016-10-13 16:37:50 UTC
https://msdn.microsoft.com/en-us/library/system.reflection.emit.opcodes.endfilter(v=vs.110).aspx

"If an exception is thrown inside the filter block, it is intercepted and a value of 0 (exception_continue_search) is returned."

.Net Output
================================
Finally block after filter
Caught exception not handled by filter

Mono Output
================================
Finally block after filter
Caught exception thrown in filter

// Test  case
using System;

class Program
{
	class FilterException : Exception { }
	class ThrowInFilterException : Exception { }

	static void Main (string[] args)
	{
		try
		{
			RaiseExceptionWithFilter (() =>
			{
				throw new ThrowInFilterException ();
			});
		}
		catch (ThrowInFilterException)
		{
			Console.WriteLine ("Caught exception thrown in filter");
		}
		catch (FilterException)
		{
			Console.WriteLine ("Caught exception not handled by filter");
		}
	}

	public static void RaiseExceptionWithFilter (Func<bool> filterFunc)
	{
		try
		{
			throw new FilterException ();
		}
		catch (FilterException ex) when (filterFunc ())
		{
			Console.WriteLine ("Caught exception in filter " + ex);
		}
		finally
		{
			Console.WriteLine ("Finally block after filter");
		}

		Console.WriteLine ("Code after filter");
	}
}

Note You need to log in before you can comment on or make changes to this bug.