ctrl+c and destructors

Walter Bright newshound2 at digitalmars.com
Thu Oct 3 17:04:02 PDT 2013


On 10/3/2013 4:49 PM, Jonathan M Davis wrote:
> Just because it won't kill anyone doesn't mean that it's okay for it to
> continue after it's in a bad state. It could do other nasty things to the
> system (including corrupt the files that it's operating on). Once a program's
> in an invalid state, all bets are off. I fully concur with Walter that it's
> better to kill the program at that point and restart it whether lives are on
> the line or not. And if that means that the user sees crashes, oh well.
> They'll complain and the developer will have to fix them, which is exactly what
> they need to do, because they wouldn't be getting stuff like segfaults or
> Errors if their code wasn't broken.

Exactly.

Note that memory corruption can also result in corruption of user data, as I 
mentioned, and it can ALSO result in corruption of your system. The music player 
can read and write files, right? Kaboom.

I was just talking to Andrei earlier about the bad old MSDOS programming days. 
There, if you had an errant pointer, it didn't seg fault. It would scramble the 
operating system tables, and having

     YOUR HARD DISK SCRAMBLED

was a not uncommon experience.

Continuing program execution after it failed due to programming bugs is just a 
bad, bad, bad idea, and it needs to die.


More information about the Digitalmars-d mailing list