Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #41219
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: asserts considered harmful |
| Date | 2016-02-24 23:14 +1300 |
| Message-ID | <dj5e3dFj7j3U9@mid.individual.net> (permalink) |
| References | (1 earlier) <naio4b$9ic$1@dont-email.me> <dj4a4tFj7j3U4@mid.individual.net> <C7adnQL08_S_ZVHLnZ2dnUU7-WmdnZ2d@giganews.com> <dj4c3sFj7j3U6@mid.individual.net> <c4SdndUwVpHs4VDLnZ2dnUU78bWdnZ2d@giganews.com> |
Paavo Helde wrote: > On 24.02.2016 2:34, Ian Collins wrote: >> >> I think you lost the way somewhere. std::logic_error has its place, but >> that place isn't as a substitute for assert. > > I think it depends very much on the modularity of the component which > has failed and needs to be restarted. > > If the OS fails with a blue screen or kernel panic, then the execution > flow goes back to the hardware and the computer is restarted either > automatically or by the user. > > If an app gets terminated via an assert, then the execution flow > basically goes back to OS and user or another program can restart the app. > > If a component in an app fails with an assert-style exception, the > execution flow goes back to the main driver component of the app and the > user or another routine can restart the component. > > If the component state is corrupted and restarting it does not work, the > next level (app) restart is needed. > > If the computer state is corrupted and the app does not work after > restart, the next level (computer) restart is needed (not a rare > scenario in Windows). > > The most tricky part is to find the correct level of restart needed at > any given situation. Assert is not always the best choice, and neither > is std::logic_error. > > Just my 2 cents. A fair summary. I agree with the theory, but I've seldom seen component restarts implemented well in practice! Most applications are monolithic, so there is nothing to restart. Long running threaded applications are a good candidate for trapping errors with exceptions and restarting a thread while multi-process applications are a good candidate for asserts. Most long running applications I've seen (such as system services) are happy to abort and rely on what ever started them to do the restart. It is often safer and no doubt easier to code them this way. -- Ian Collins
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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