RFC: Change what assert does on error
Dennis
dkorpel at gmail.com
Fri Jul 4 09:54:51 UTC 2025
On Friday, 4 July 2025 at 07:51:00 UTC, Jonathan M Davis wrote:
> For instance, Timon does this already with programs that actual
> users use. It's just that he has to work around the fact that
> not all of the clean up code gets run (some of it does, and
> some of it doesn't), and the fact that some of the clean up
> code is skipped means that he's risking memory safety issues in
> the process that wouldn't have been there if the stack had
> unwound properly. It also potentially means that he'll miss
> some of the information that he's trying to log so that the
> user can give him that information. And that information is
> critical to his ability to fix bugs
So the argument is that even when you don't recover from Error,
it's still desirable to run all (implicit) `finally` blocks when
unwinding the stack because that results in a better error log.
Maybe only Timon can answer this, but what kind of clean up are
you doing that makes this important? An example of an error log
with and without complete stack unwinding would be illuminating.
Looking at my own destructors / scope(exit) blocks, they mostly
just contain `free`, `fclose`, `CloseHandle`, etc. In that case I
agree with Walter: when my program trips an assert, I don't need
calls to `free` since that could only lead to more memory
corruption, and resource leaks are irrelevant when the program is
going to abort shortly.
More information about the Digitalmars-d
mailing list