Re: Secure C library



On 2005-10-04 15:49, Douglas A. Gwyn wrote:
> Niklas Matthies wrote:
>> Who said anything about jumping back into the interrupted processing?
>
> That's the only real advantage in maintaining the current call stack.

No. For one, having the current call stack available for diagnostic
purposes (e.g. as part of a core dump) is a real advantage.

>> ... If the callback returns, then the
>> default handling will occur, which again will typically either be to
>> terminate the process or to throw an exception.
>
> Termination is not appropriate, since that is a high-level strategy
> being imposed by low-level code which is not aware of the whole
> context.

The strategy is imposed by the code that registers the callback, which
generally will be high-level code. More generally, the callback can be
registered anylevel an exception handler can be placed; the respective
level is then equally appropriate or inappropriate for both.

Furthermore, by your reasoning, usage of assert() would never be
appropriate.

> Having to code two levels of error recovery everywhere that an
> exceptional condition could occur is a disadvantage.

The callback is not about error recovery. It's about selecting the
handling mechanism.

Also note that with nested exception handlers, you have multiple
potential levels of error recovery pretty much the same. Just as
exception handlers generally have no problem with the fact that
there might be some inner nested exception handler that catches the
exception first, they won't have a problem with the callback handling
the situation first.

>> .... But, as seen above, there other ways to react (including the
>> possibility to just throw a different, application-specific
>> exception).
>
> Any reasonable nested exception handler system also aupports that.

For that you have to catch the original exception first, possibly in a
multitude of places (before the exception reaches code that expects
the application-specific exception). The purpose of having the
application-specific exception thrown in the first place is exactly to
avoid having to riddle the code with exception-converting handlers.

>> A callback allows client programmers to choose what is appropriate
>> for their application.
>
> Ditto.

Not true. For one, there are applications for which exceptions are not
appropriate, for example if the exceptions would pass through legacy
code that don't expect them and therefore would leak resources.

>> By "stack unwinding" I mean to include a) the process of tracing the
>> chain of exception handlers up the stack (which might be corrupted)
>> and b) all cleanup work done by intermediate exception handlers.
>
> Yes, I know what it means. It's not necessary.

You'll have to explain this. Certainly the next (matching) exception
handler has to be determined somehow for it to be executed, and
certainly there will be exception handlers for releasing resources
that were acquired in local scopes by intermediate code.

-- Niklas Matthies
.



Relevant Pages

  • Re: YHO about Try-Catch use.
    ... great in moderation, but for some reason people ... An exception handler is a tool for error recovery. ... use of exception handlers, but the stress is on "strategic". ... Exception handlers for debugging are bogus. ...
    (microsoft.public.dotnet.general)
  • Re: Secure C library
    ... >> that exception handlers only kick in after unwinding, ... Typically the callback will either abort or exit the process (because ...
    (comp.std.c)
  • Re: YHO about Try-Catch use.
    ... An exception handler is a tool for error recovery. ... You first think about what sort of error recovery you're going to need and how to best achieve that, then you write code that keeps it in mind. ... This will involve strategic use of exception handlers, but the stress is on "strategic". ... Exception handlers for debugging are bogus. ...
    (microsoft.public.dotnet.general)
  • Re: Exception management question...
    ... > are actually events generated by different libraries that wrap execution ... >> AppDomain.UnhandledException or to all three Global Exception Handlers? ... >> correctly written so it doesn't need any exception handling! ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: jad gibt Fehlermeldung aus
    ... Not all exception handlers will be ... Der Code ist auch nur sehr schwer zu gebrauchen. ...
    (de.comp.lang.java)