[Issue 13723] onFinalizeError should not be called for Errors

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Nov 12 17:39:49 PST 2014


https://issues.dlang.org/show_bug.cgi?id=13723

Vladimir Panteleev <thecybershadow at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

--- Comment #2 from Vladimir Panteleev <thecybershadow at gmail.com> ---
Despite the exception chaining, there is still value in the proposal, in the
following scenario:

- A critical memory error (OutOfMemory / InvalidMemoryOperation) occurs
somewhere during the execution of a finalizer.
- Because of the nature of the error, the .init is thrown to avoid any
allocations.
- Thus, the stack trace is not saved in the exception object.
- The only way to see a stack trace of what caused the exception to be thrown
is to stop the program in a debugger at the point where an exception is
created.
- On Windows, the Druntime default exception handler is purposefully disabled
if the program is running under a debugger.
- Thus, usually, the user only needs to run a D program in a debugger, and it
will stop at the first unhandled exception.
- However, this will not work if the exception is caught in order to be chained
/ rethrown, which is what onFinalizeError does.

Thus, because of the chaining, the call stack which caused
InvalidMemoryOperationError to be thrown is irreversibly lost. The user needs
to explicitly breakpoint onInvalidMemoryOperation instead (which is currently
not possible because of issue 13725).

--


More information about the Digitalmars-d-bugs mailing list