Global object's destructor not called when code crashes

Started by
10 comments, last by markr 13 years, 4 months ago
just make sure the logfile actually has data in, even if the log destructor isn't called. that can often be a problem, then.

for your other points, yes of course. that's why i love RAII.

have fun doing the lowlevel stuff. i remember it from long time ago :)
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

Advertisement
@Dave: yes it was so much Fun!! I've never felt like this before, oh wel...
To All: MERRY CHRISTMAS GUYS! have a good one here :D
When the code crashes, you can't rely on *anything* happening.

A crash could be a hardware failure. It could bluescreen the OS; it could lock the system solid. So even files which were written before the crash, aren't safe unless you fsync()'d them and got back a positive result (This assumes the machine has non-lying hardware)

A really robust application should be able to recover from any kind of shutdown, including an OS / hardware failure; this means that a program crash is relatively "clean".

If you read up on the principle "crash-only", you'll realise, that doing anything in your global destructor is essentially futile (or at best, unnecessary).

A crash-only program should not rely on a global destructor being executed, or indeed any other destructor, if the program stops executing.

"Stops executing" here, meaning that it's not running any more, as a result of a normal quit operation, program crash, OS crash, hardware failure, intercontintenal thermonuclear war etc.

This topic is closed to new replies.

Advertisement