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 (show other bugs)
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)

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


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.

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