Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #41240

Re: asserts considered harmful

From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c++
Subject Re: asserts considered harmful
Date 2016-02-25 15:29 +1300
Message-ID <dj778qFj7j3U12@mid.individual.net> (permalink)
References (2 earlier) <6a6dndcqc5TVdFHLnZ2dnUU7-eednZ2d@giganews.com> <P9SdnZ8hitjVvVPLnZ2dnUU78cmdnZ2d@brightview.co.uk> <2767e6c3-449d-4370-abc2-52556c35493a@googlegroups.com> <tFrzy.2630$_f2.721@fx20.iad> <nalhcd$s37$1@dont-email.me>

Show all headers | View raw


David Brown wrote:
> On 25/02/16 01:12, Scott Lurndal wrote:
>> =?ISO-8859-1?Q?=D6=F6_Tiib?= <ootiib@hot.ee> writes:
>>> On Wednesday, 24 February 2016 23:27:53 UTC+2, Vir Campestris  wrote:
>>>>
>>>> But when the code is out in the field - imagine a word processor. The
>>>> use has been typing for an hour, and hasn't saved. He inserts some funny
>>>> field, the program asserts, and he loses his edits. Or the program
>>>> doesn't assert, does its best to recover the error, forgets how it got
>>>> in that situation - but there's at least a chance of saving the document.
>>>
>>> Aborting in unexpected state is likely safest choice for any serious
>>> software.
>>
>> Most serious software (e.g. safety critical or life critical) cannot _abort_
>> in unexpected state. It needs to fail safe, which isn't just calling 'assert'.
>>
>> We allow static_assert for compile-time invariants, but never asserts at
>> runtime for any reason.
>>
>
> That would depend on what you mean by "abort".  For some safety systems,
> an "abort" that immediately disabled all outputs then hangs the
> processor could be the ideal fail-safe behaviour.  Or perhaps "abort"
> could be used to force the hardware to restart with a minimal fail-safe
> firmware image.  You are free to implement "abort" in whatever way makes
> sense for the system in question.

Those were certainly considerations for the last few control systems I 
worked on.  The last was a propulsion and helm control system where a 
dead stop, painful as it could be, was better than destroying an engine 
or ramming a jetty at 40 knots!  An earlier example was a telco power 
system controller, again, aborting (via assert) and falling back to 
hardware defaults was better than allowing outputs that could fry 
millions of dollars of kit.

As you say, the result of a "abort" will vary from system to system but 
in all cases it must happen immediately when a problem is detected, not 
after some potentially catastrophic attempts at clean up.

-- 
Ian Collins

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

asserts considered harmful Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-02-23 22:19 +0000
  Re: asserts considered harmful Ian Collins <ian-news@hotmail.com> - 2016-02-24 11:27 +1300
    Re: asserts considered harmful Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-02-23 22:32 +0000
      Re: asserts considered harmful Ian Collins <ian-news@hotmail.com> - 2016-02-24 11:44 +1300
    Re: asserts considered harmful Cholo Lennon <chololennon@hotmail.com> - 2016-02-24 16:49 -0300
  Re: asserts considered harmful "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2016-02-24 00:00 +0100
    Re: asserts considered harmful Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-02-23 23:20 +0000
      Re: asserts considered harmful "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2016-02-24 01:02 +0100
        Re: asserts considered harmful Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-02-24 00:17 +0000
          Re: asserts considered harmful Ian Collins <ian-news@hotmail.com> - 2016-02-24 13:25 +1300
      Re: asserts considered harmful Vir Campestris <vir.campestris@invalid.invalid> - 2016-02-24 21:27 +0000
        Re: asserts considered harmful Ian Collins <ian-news@hotmail.com> - 2016-02-25 10:59 +1300
        Re: asserts considered harmful Öö Tiib <ootiib@hot.ee> - 2016-02-24 14:13 -0800
          Re: asserts considered harmful scott@slp53.sl.home (Scott Lurndal) - 2016-02-25 00:12 +0000
            Re: asserts considered harmful David Brown <david.brown@hesbynett.no> - 2016-02-25 01:23 +0100
              Re: asserts considered harmful Ian Collins <ian-news@hotmail.com> - 2016-02-25 15:29 +1300
                Re: asserts considered harmful Vir Campestris <vir.campestris@invalid.invalid> - 2016-02-25 23:05 +0000
                Re: asserts considered harmful Ian Collins <ian-news@hotmail.com> - 2016-02-26 19:41 +1300
                Re: asserts considered harmful David Brown <david.brown@hesbynett.no> - 2016-02-26 17:11 +0100
            Re: asserts considered harmful Öö Tiib <ootiib@hot.ee> - 2016-02-24 17:32 -0800
    Re: asserts considered harmful Ian Collins <ian-news@hotmail.com> - 2016-02-24 13:00 +1300
      Re: asserts considered harmful Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-02-24 00:24 +0000
        Re: asserts considered harmful Ian Collins <ian-news@hotmail.com> - 2016-02-24 13:34 +1300
          Re: asserts considered harmful Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-02-24 01:21 +0000
            Re: asserts considered harmful Ian Collins <ian-news@hotmail.com> - 2016-02-24 14:55 +1300
            Re: asserts considered harmful Öö Tiib <ootiib@hot.ee> - 2016-02-23 18:47 -0800
              Re: asserts considered harmful Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-02-24 17:52 +0000
                Re: asserts considered harmful Öö Tiib <ootiib@hot.ee> - 2016-02-24 11:14 -0800
                Re: asserts considered harmful Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-02-24 19:42 +0000
                Re: asserts considered harmful Öö Tiib <ootiib@hot.ee> - 2016-02-24 12:58 -0800
                Re: asserts considered harmful Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-02-24 21:49 +0000
                Re: asserts considered harmful Öö Tiib <ootiib@hot.ee> - 2016-02-24 14:03 -0800
          Re: asserts considered harmful Paavo Helde <myfirstname@osa.pri.ee> - 2016-02-24 11:48 +0200
            Re: asserts considered harmful Ian Collins <ian-news@hotmail.com> - 2016-02-24 23:14 +1300
            Re: asserts considered harmful Öö Tiib <ootiib@hot.ee> - 2016-02-24 05:52 -0800
          Re: asserts considered harmful woodbrian77@gmail.com - 2016-03-09 11:32 -0800
      Re: asserts considered harmful mark <mark@invalid.invalid> - 2016-02-24 14:43 +0100
        Re: asserts considered harmful Öö Tiib <ootiib@hot.ee> - 2016-02-24 06:22 -0800

csiph-web