Re: Why leave the error handling to the caller?



Malcolm McLean wrote, On 19/06/07 20:37:

"Flash Gordon" <spam@xxxxxxxxxxxxxxxxxx> wrote in message news:4bogk4xq23.ln2@xxxxxxxxxxxxxxxxxxxxxxxxxx
Malcolm McLean wrote, On 17/06/07 22:40:

"Eric Sosman" <esosman@xxxxxxxxxxxxxxxxxxx> wrote in message news:HYqdneY53-HiBOjbnZ2dnUVZ_jGdnZ2d@xxxxxxxxxxxxxx
Malcolm McLean wrote:

"Richard Heathfield" <rjh@xxxxxxxxxxxxxxx> wrote in message news:7oCdnWXORp3b-ujbnZ2dnUVZ8szinZ2d@xxxxxxxxx
Malcolm McLean said:

<snip>

There quite a strong case for a safemalloc() library function that
does terminate with an error message on fail.

No, there isn't. Library routines have no business deciding to terminate
the program.

The problem is that the code is disproprtionate. [...]
> [code snipped; see up-thread]

<snip>

Should fprintf() halt the program on an I/O error?

Should fopen() halt the program if unable to open the file?

Should strtod() halt the program on a malformed input?

Then why should malloc() halt the program on a whim?

The Turing machine has run out of tape. That's a different kind of problem to the others you have described.

It is a recoverable error in many situations just as all the others are. For example, when stressing my company notebook several times I've had VMware tell me it was out of memory giving the option to retry. I closed down some other stuff, told it to retry, and continued with my work. Far better than your approach of having it die on me.

But what if you don't have a program at all because with the 33:67 payload to malloc recovery ratio, it costs too much to write?

That's rubbish according to your own attempt at showing how bad the ratio is.

Sometimes it's an issue, sometimes not. If you are writing Microsoft's next OS you have practially infinite resources.

That's rubbish because the above situation is on a modern (only a couple of months old) medium to high spec notebook.

On my previous company notebook which was high spec at the time I would also run out of resources.

I've seen servers run out of resources, including high spec ones.

> If you're knocking up a
game on a tight budget, it is no good missing Christmas. If it crashes out one every hundred hours of gameplay, that's not ideal but it isn't the end of the world either. If it is two months late it might be canned, then you get zero royalties, and no-one will ever play it.

If it crashes too often because it is badly written no one will buy it. In one extreme case a game got canned because after it was produced they found it contained a virus, so there they lost a lot more money. I'm sure others have failed to make it to market, or failed to have significant sales, due to too many bugs.
--
Flash Gordon
.



Relevant Pages

  • Re: How do you kill a completely locked up thread?
    ... terminate a process any more than you can safely abort a thread. ... you can manage your external resources in such a way that it's ok for the ... being left in an inconsistent state. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: C# Threading, and suspending or killing a thread
    ... Other threads that are spawned like this go right back to zero CPU, ... the Process Explorer to kill it there. ... When you terminate a thread in a .NET application you should consider the whole appdomain doomed, as in, you should no longer keep it around. ... - deadlocks, if the thread locks internal resources it will never unlock them, thus blocking future threads from ever accessing the resources the lock protects ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: xp pro rebbots for no apperant reason
    ... winlogin.exe failed click ok to terminate or cancel to debug ... go to boot seliction screen and selected safe mode with network support as ... rebooted system through reset button this time error message came up as ... Try to get back to the Windows XP Startup Menu ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: INTERNAL COMPILER ERROR ???
    ... I suspect that if you have some large resources ... I get this error message every so often, ... > I suspect the real problem is that our code (mine is definitely ... > included) exceeds some resource limit for the compiler. ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: contracted exceptions
    ... superior to the existing rule of silently ignoring the exception. ... The simplest would be to terminate the entire program immediately. ... And print an error message on systems where that makes sense. ... Terminate the parent task and that should become equivalent to "exit". ...
    (comp.lang.ada)