fix Issue 14036 - Do not throw FinalizeError on OutOfMemoryError or Inva... #1123
Conversation
CC @MartinNowak |
1af6b03
to
2d540e4
Compare
|
||
assert( test!Exception); | ||
import core.exception : InvalidMemoryOperationError; | ||
assert(!test!InvalidMemoryOperationError); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you'll have to catch the memory error to successfully pass the unittest.
2d540e4
to
f0cd924
Compare
I agree that not catching Errors is better. |
…nvalidMemoryOperationError This changes FinalizeError to be thrown only when an Exception is thrown, with the disadvantage of not catching non-Exception Throwables and the advantage of preserving the stack trace for the code that caused InvalidMemoryOperationError.
f0cd924
to
73d7a44
Compare
Finally fixed tests. |
Auto-merge toggled on |
Why was the stacktrace of Throwable.next missing? |
We can allocate neither a stack trace nor a FinalizeError in an InvalidMemoryOperation condition. |
To clarify, I was talking about the stack trace in the debugger. If we catch and rethrow, the stack trace of the point where the exception was thrown is lost (unless it was saved in the exception object, which it was not). |
fix Issue 14036 - Do not throw FinalizeError on OutOfMemoryError or Inva...
With an InvalidMemoryError or OutOfMemoryError, would it be a viable choice to simply claim that all memory currently allocated is free to be used by the runtime to output useful information, such as a stack trace. Both of these errors are impossible to recover from, so the best we can do is hope that the current state is at least valid enough to be able to use the space for a stack trace. |
That might do more harm than good, e.g. corrupt user data. |
It would also be easier to use C malloc, or allocate directly from the OS (for the case of InvalidMemoryOperation). |
A short transcript of the ensuing IRC conversation: CyberShadow: In both of those cases though, there's nothing you can do about it, the program IS going to crash, so why does it matter if we corrupt user data? |
A stack trace for OOM is misleading and InvalidMemoryError will be fixed at some point. |
...lidMemoryOperationError
This changes FinalizeError to be thrown only when an Exception is thrown,
with the disadvantage of not catching non-Exception Throwables and the
advantage of preserving the stack trace for the code that caused
InvalidMemoryOperationError.
https://issues.dlang.org/show_bug.cgi?id=14036