Bug 11549 – Throwing an exception while debugging causes incorrect execution
Status
RESOLVED
Resolution
FIXED
Severity
blocker
Priority
P2
Component
visuald
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2013-11-18T23:00:00Z
Last change time
2014-12-30T01:25:52Z
Keywords
symdeb
Assigned to
nobody
Creator
turkeyman
Comments
Comment #0 by turkeyman — 2013-11-18T23:00:26Z
While debugging 32bit, when the program encounters a throw, the debugger stops and produces a pop-up dialog box (even if the D exceptions are disabled in "Debug -> Exceptions...".
The usual options are present (continue, ignore, terminate), but what happens next gets weird.
With Mago:
Pressing continue causes the program to continue execution _instead of unwinding_ as if the exception were never thrown, which leads to execution of code that shouldn't be reachable.
This completely changes the execution path of code while debugging (doesn't ever enter any catch blocks), and since code following the throw shouldn't be reachable, it typically crashes immediately.
With Visual Studio's debugger:
Pressing 'continue' then produces a second request "Would you like to pass the exception back to the program being debugged".
Choosing 'yes' then produces the first dialog box again, and choosing 'continue' from there repeats the first dialog over and over continuously from every single point in the unwind process, although the code does appear to successfully unwind.
This is a critical issue while debugging. It is impossible to debug code that contains exceptions with either debugger. Mago is simply broken, and visual studio is practically unusable.
Are there any known work-arounds?
Comment #1 by r.sagitario — 2013-11-19T00:30:26Z
See also issue 11033.
I don't have the same issues you describe, though I mostly use the VS debugger.
Which VS version and debug engine do you use? Do you have "native edit and continue" enabled (see the VS 2012 section at http://rainers.github.io/visuald/visuald/Debugging.html )
Regarding the issues with the exceptions dislaog not being functional for mago, this might be related to the "Exceptions with Mago" section on the same page.
Comment #2 by turkeyman — 2013-11-19T02:51:10Z
(In reply to comment #1)
> See also issue 11033.
Ah sorry, that's also mine. I didn't see that it was migrated. Sorry!
> I don't have the same issues you describe, though I mostly use the VS debugger.
> Which VS version and debug engine do you use? Do you have "native edit and
> continue" enabled (see the VS 2012 section at
> http://rainers.github.io/visuald/visuald/Debugging.html )
I'm using VS2010, so I guess that option doesn't apply?
I described the behaviour under both Mago and Visual Studio. Neither of them are working in an acceptable manner for me.
> Regarding the issues with the exceptions dislaog not being functional for mago,
> this might be related to the "Exceptions with Mago" section on the same page.
I have all D Exceptions unchecked. I don't want it to break on exceptions at all, but I can't seem to control it with those options.
Comment #3 by r.sagitario — 2013-11-24T10:01:06Z
I just tried it again with the example referenced by issue 11033: it just works for me.
What you describe for mago is what happens when you press "ignore", but that is expected behaviour. The same holds for answering "no" to the "Pass exception on to program being debugged?" question when continuing after stopping at the exception. Do these options behave identically for you?
Regarding stopping on specific exceptions: if you want to treat an exception differently than others, it must be added explicitely to the list of exceptions, e.g. as "main.WLServException". Mago doesn't check base classes of an unlisted exception.
>I'm using VS2010, so I guess that option doesn't apply?
Yes, it is only for VS2012 and later.
>I have all D Exceptions unchecked. I don't want it to break on exceptions at
>all, but I can't seem to control it with those options.
The "D Exceptions" top level entry is only for mago, disabling this root entry and all sub-entries should work.
The VS debug engine interprets D's exceptions as Win32 Exceptions, so you'll have to disable entry 0xe0440001.
Comment #4 by r.sagitario — 2014-08-02T13:13:35Z
> I just tried it again with the example referenced by issue 11033: it just works for me.
When trying this again with mago, I noticed that the breakpoint in the catch branch of the template function does not trigger: it only set the breakpoint on the first instance of the template.
This is fixed in mago and can be tested with this beta: https://github.com/D-Programming-Language/visuald/releases/tag/v0.3.39-beta1
Comment #5 by turkeyman — 2014-12-30T01:25:52Z
I've tried debugging various bits of code with exceptions with the latest tools. I can't seem to reproduce this issue anymore.
Thanks again!