comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: How to get nice with GNAT?
Date: Tue, 25 Nov 2014 16:12:07 -0600
Date: 2014-11-25T16:12:07-06:00	[thread overview]
Message-ID: <m52urp$9nc$1@loke.gir.dk> (raw)
In-Reply-To: 8f203a9a-6c7c-4614-bc7d-efa65bf10776@googlegroups.com

<ake.ragnar.dahlgren@gmail.com> wrote in message 
news:8f203a9a-6c7c-4614-bc7d-efa65bf10776@googlegroups.com...
>Of course I always listen seriously to Jeff Carter but it's not obvious to 
>me that doing
>"C in Ada" is bad.

It's bad. :-)

> If I remember correctly Google employees are recommended to avoid using 
> exceptions
>when doing C++. The designers of Google Go has gone great lengths to avoid 
>the exception
>concept as much as possible.

Very bad advice, IMHO. With one exception (pun intended):

> In addition SPARK forbids usage of exceptions.

While I think SPARK would be better served with limited exception support, 
at least they require a proof that no exceptions can be raised.

The reason I feel so strongly about this is that exceptions (especially 
Constraint_Error and Program_Error) point out bugs in your code. Whenever 
you "eat" an exception (turning it into an error code, or simply ignoring 
it), you've put an opportunity to ignore a bug into your code. With all of 
the potential problems that entails.

To take a concrete example. My web server runs with all exceptions enabled, 
and there is very little handling of exceptions (there are a few cases where 
expected exceptions are handled, as when a TCP/IP connection is unexpectedly 
dropped). Mainly, the worker tasks handle any surprise exceptions, log them, 
and reset everything in that task to a fresh state. Doing this prevents most 
bugs from causing security problems -- while a crafted input might cause one 
worker to fail, that only causes the sender to get no response. Other 
connections (workers) are uneffected, and there is almost no chance of a 
detected bug from overwriting memory or disk or any of the other things that 
cause security problems.

Exceptions surely aren't enough to prevent all security issues, but they can 
help avoid a substantial number of them.

(As previously noted, if you could prove that no exceptions are possible - 
meaning that no low-level bugs are possible - that would be better than 
having to figure out last-chance handlers and the like, but that's still 
beyond the state of the art for general purpose code. When that changes, 
I'll reconsider my stance on exceptions, but not until then.)

                                                  Randy.



  parent reply	other threads:[~2014-11-25 22:12 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-21 11:41 How to get nice with GNAT? Natasha Kerensikova
2014-11-21 12:42 ` Björn Lundin
2014-11-21 22:55 ` Randy Brukardt
2014-11-21 23:13   ` Björn Lundin
2014-11-22  9:45   ` How to get nice traceback " Natasha Kerensikova
2014-11-22  9:57     ` Dmitry A. Kazakov
2014-11-24 22:35     ` Randy Brukardt
2014-11-22 10:11 ` How to get nice " gautier_niouzes
2014-11-22 10:40   ` Natasha Kerensikova
2014-11-22 22:44 ` brbarkstrom
2014-11-22 23:24   ` Jeffrey Carter
2014-11-23 18:06   ` Björn Lundin
2014-11-23 16:13 ` brbarkstrom
2014-11-23 16:18   ` J-P. Rosen
2014-11-23 17:02   ` Jeffrey Carter
2014-11-23 17:41 ` brbarkstrom
2014-11-23 19:22   ` Simon Wright
2014-11-23 20:49   ` Jeffrey Carter
2014-11-24  3:05     ` brbarkstrom
2014-11-24  6:25       ` Jeffrey Carter
2014-11-24 14:39         ` brbarkstrom
2014-11-24 17:42       ` Dennis Lee Bieber
2014-11-25 13:45         ` brbarkstrom
2014-11-25 15:07           ` ake.ragnar.dahlgren
2014-11-25 15:51             ` brbarkstrom
2014-11-25 16:52             ` Jeffrey Carter
2014-11-25 19:18             ` G.B.
2014-11-25 20:47               ` brbarkstrom
2014-11-25 22:12             ` Randy Brukardt [this message]
2014-11-25 23:30               ` Simon Wright
2014-11-26  1:25                 ` G.B.
2014-11-26  7:35                   ` Simon Wright
2014-11-26 11:55                     ` Georg Bauhaus
2014-11-26 13:06                       ` Dmitry A. Kazakov
2014-11-26 13:36                         ` brbarkstrom
2014-11-26 21:27                         ` Randy Brukardt
2014-11-26 22:38                           ` brbarkstrom
2014-11-27  9:01                             ` Dmitry A. Kazakov
2014-11-27 13:53                               ` brbarkstrom
2014-11-27 17:19                                 ` Dmitry A. Kazakov
2014-12-01 22:25                                   ` Randy Brukardt
2014-12-02  8:42                                     ` Dmitry A. Kazakov
2014-12-03 21:41                                       ` Randy Brukardt
2014-12-06 12:02                                         ` Dmitry A. Kazakov
2014-12-08 22:45                                           ` Randy Brukardt
2014-12-09  8:51                                             ` Dmitry A. Kazakov
2014-12-09 23:14                                               ` Brad Moore
2014-12-09 17:59                                                 ` Dmitry A. Kazakov
2014-11-27  8:52                           ` Dmitry A. Kazakov
2014-11-26  6:18                 ` J-P. Rosen
2014-11-26  7:37                   ` Simon Wright
2014-11-26  8:41               ` Dmitry A. Kazakov
2014-11-25 18:33           ` Dennis Lee Bieber
2014-11-26  1:27             ` Dennis Lee Bieber
2014-11-26  3:29               ` brbarkstrom
2014-11-23 18:55 ` brbarkstrom
2014-11-23 19:30 ` brbarkstrom
2014-11-23 22:38   ` Simon Wright
2014-11-24  2:47     ` brbarkstrom
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox