Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

If something_really_bad_happens in g(), the function prints an error message to stderr and then calls abort(). The problem is that this application-independent code does not know the context in which it is being called, so it is erroneous to handle the error.

Wiki Markup\[[Miller 2004|AA. Bibliography#Miller 04]\], Practice 23 says

When a library aborts due to some kind of anomaly, it is saying there is no hope for execution to proceed normally beyond the point where the anomaly is detected. Nonetheless, it is dictatorially making this decision on behalf of the client. Even if the anomaly turns out to be some kind of internal bug in the library, which obviously cannot be resolved in the current execution, aborting is a bad thing to do. The fact is, a library developer cannot possibly know the fault-tolerant context in which his/her library is being used. The client may indeed be able to recover from the situation even if the library cannot.

...

While this error handling approach is secure, it has the following drawbacks:

...

CERT C++ Secure Coding Standard: ERR05-CPP. Application-independent code should provide error detection without dictating error handling

Bibliography

Wiki Markup\[[Miller 2004|AA. Bibliography#Miller 04]\] \[]
[Saks 2007b|AA. Bibliography#Saks 07b]\]

...

      12. Error Handling (ERR)