Bug 39371 - Filtering exception that is thrown and caught in non-user code is not working correctly
Summary: Filtering exception that is thrown and caught in non-user code is not working...
Status: NEW
Alias: None
Product: Runtime
Classification: Mono
Component: Debugger ()
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: Zoltan Varga
Depends on:
Blocks: 39345 39346 51684
  Show dependency tree
Reported: 2016-03-04 17:51 UTC by David Karlaš
Modified: 2017-08-23 23:13 UTC (History)
6 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 for Bug 39371 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description David Karlaš 2016-03-04 17:51:44 UTC
1st problem: This `for` looks weird(it loops way more then it should): https://github.com/mono/mono/blob/bcd5485c4/mono/mini/debugger-agent.c#L5573

2nd problem: https://github.com/mono/mono/blob/master/mono/mini/debugger-agent.c#L5578 caught is set to false here which makes this logic: https://github.com/mono/mono/blob/master/mono/mini/debugger-agent.c#L3421-L3424 think we have unhadled exception, which is not true, we got handled exception just not by user code... results into unhandled exception catchpoint to be raised...

3rd problem: This logic https://github.com/mono/mono/blob/master/mono/mini/debugger-agent.c#L5559-L5581
Should walk the stack between `throw_ctx` and `catch_ctx` and check each method if it's in user code or not, because in example below(read comments):

Non-User code:
public class Class1
  public void Throw ()
    throw new Exception ("An Exception");

  public void CallMeAndHandle (Action callback)
    try {
      callback ();
    } catch (Exception e) {

User code:
static void Main(string[] args)
  var x = new Class1();
  x.CallMeAndHandle (() => {
    x.Throw ();//Exception should be thrown
    //because user code is between throw and catch
Comment 1 Lluis Sanchez 2016-06-29 18:59:25 UTC
Zoltan, ping.
Comment 3 Zoltan Varga 2017-08-23 23:03:15 UTC
So what is the problem here ? The debugger doesn't stop at a certain exception where it should ? Or the reverse ?
Comment 4 Nate Cook 2017-08-23 23:13:12 UTC
The reverse. The debugger stops on exceptions that are raised (and caught) not in user code. The expected behavior is that the debugger does not stop at all, because the caught exception did not occur in user code.