| |
 | Posted by Sebastiaan Koppe in reply to Walter Bright | Permalink Reply |
|
Sebastiaan Koppe 
Posted in reply to Walter Bright
| On Wednesday, 2 July 2025 at 08:11:44 UTC, Walter Bright wrote:
> On 6/30/2025 2:18 PM, Sebastiaan Koppe wrote:
>> Just know that the idea of exiting directly when something asserts on the pretense that continueing makes things worse breaks down in multi-threaded programs.
>
> An assert tripping means that you've got a bug in the program, and the program has entered an unanticipated, unknown state. Anything can happen in an unknown state, for instance, installing malware. As the threads all share the same memory space, doing something other than aborting the process is highly unsafe.
>
> Depending on one's tolerance for risk, it might favor the user with a message about what went wrong before aborting (like a backtrace).
>
> But continuing to run other threads as if nothing happened is, bluntly, just wrong. There's no such thing as a fault tolerant computer program.
I absolutely understand your stance. There are programs where I would blindly follow your advice. It's just that there 99x as many where graceful shutdown is better.
Also, most triggered asserts I have seen were because of programmer bugs, as in, they misused some library for example, not because of actual corruption or violation of some basic axiom.
> D is flexible enough to allow the programmer to do whatever he wants with an assert failure, but I strongly recommend against attempting to continue as if everything was normal.
Exactly. People who design highly critical systems can be assumed to know how to flip the default handler.
> BTW, when I worked at Boeing on flight controls, the approved behavior of any electronic device was when it self-detected a fault, it immediately activated a dedicated circuit that electrically isolated the failed device, and engaged the backup system. It's the only way to fly.
Good for Boeing, not for my apps.
Having said that, I do see some parallel with large-scale setups where backend servers often employ health checks to signal they are ok to receive requests.
Similarly, during deployment of new software people often use error rates as an indication whether to continue rollout or back out instead.
There is wisdom in all that, I don't deny that. But again, people in that position are smart enough to configure the runtime to abort at first sight, if that is what they want. For my little cli app I rather want graceful shutdown instead.
|