Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.iso-c++ > #1974
| Path | csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Stefan Reuther <stefan.news@arcor.de> |
| Newsgroups | de.comp.lang.iso-c++ |
| Subject | Re: Exception mit Durchfall? |
| Date | Fri, 25 Nov 2016 18:07:52 +0100 |
| Organization | A noiseless patient Spider |
| Lines | 80 |
| Sender | "Moderation de.comp.lang.iso-c++" <dclisocpp+mod@elaboris.de> |
| Approved | White-List <dclisocpp+mod@elaboris.de> |
| Message-ID | <o19ulo.5ek.1@stefan.msgid.phost.de> (permalink) |
| References | <o0mvct$30v$1@news2.open-news-network.org> <o0s0q8.2so.1@stefan.msgid.phost.de> <o14123$9bf$1@news2.open-news-network.org> <o17e8r.4ng.1@stefan.msgid.phost.de> <o18o8d$4c6$1@news2.open-news-network.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252 |
| Content-Transfer-Encoding | 8bit |
| Injection-Info | mx02.eternal-september.org; posting-host="cee8b487d1bc34177ac416344fbcf2c5"; logging-data="25215"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+QX70Mh66b3YnNx1LM0r7k" |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.0 Hamster/2.1.0.1538 |
| Xref | csiph.com de.comp.lang.iso-c++:1974 |
Show key headers only | View raw
Am 25.11.2016 um 08:11 schrieb Edzard Egberts:
> Stefan Reuther wrote:
>> Am 23.11.2016 um 13:11 schrieb Edzard Egberts:
>>> Ansonsten kann ich also zu Recht davon ausgehen, dass eine Exception
>>> nicht irgendwo den Ausgang nimmt, sondern immer durchgereicht wird?
>>> Ich habe das gesamte Programm in einer try-catch(...), aber da ist
>>> noch nie ein Absturz angekommen.
>>
>> try-catch ist kein magisches "du kommst hier nicht raus außer an mir
>> vorbei". Neben exit(), assert() o.ä. sowie den Syscalls der Wahl (z.B.
>> kill()) ist da eben noch die Möglichkeit, dass während des Aufräumens
>> auf dem Weg zum catch eine weitere Exception geworfen wird. Und dann ist
>> halt Ende.
>
> Na ja, das ist dann wohl der Punkt, wo lokale Fehlerbearbeitung den
> Exceptions überlegen ist.
Nein, das ist der Punkt, wo man prüfen sollte, ob man nicht doch im
Destruktor auf Exceptions verzichten sollte. Gefährlicher Code steht da
ja meist aus Bequemlichkeit, z.B. der automatische flush eines Streams.
Und wenn's doch nicht ohne geht, dann im Destruktor wenigstens ein
try/catch drum.
>>> Wäre das ein neuer Pfad, der nicht abgefangen wird?
>>
>> Das ist ein Pfad, der nicht abgefangen werden kann. Das Programm kann ja
>> schlecht sagen "whoops, das Zerstören dieses Objektes beim Verlassen der
>> Funktion schlug fehl.
>
> Einfach abkacken ist aber auch nicht die feine Art, zumindest der
> Debugger sollte da anhalten.
Windows weiß ich nicht, aber unixoide Debugger tun das: terminate() ruft
abort() auf, abort() generiert SIGABRT, und das Signal fängt der Debugger.
Cygwin:
$ cat x.cpp
class foo {
public:
~foo() { throw "bar"; }
};
int main()
{
foo f;
}
$ g++ x.cpp
$ gdb ./a.exe
GNU gdb (GDB) 7.8
[...]
Reading symbols from ./a.exe...done.
(gdb) r
Starting program: /cygdrive/e/home/a.exe
[New Thread 2724.0x1454]
[New Thread 2724.0xa30]
[New Thread 2724.0x14ac]
[New Thread 2724.0x518]
terminate called after throwing an instance of 'char const*'
Program received signal SIGABRT, Aborted.
0x0028dd58 in ?? ()
(gdb) bt
#0 0x0028dd58 in ?? ()
#1 0x761e1194 in WaitForSingleObjectEx () from /cygdrive/c/Windows/syswow64/kernel32.dll
#2 0x761e1148 in WaitForSingleObject () from /cygdrive/c/Windows/syswow64/kernel32.dll
#3 0x610f0500 in sig_send(_pinfo*, siginfo_t&, _cygtls*) () from /usr/bin/cygwin1.dll
#4 0x610ed41c in _pinfo::kill(siginfo_t&) () from /usr/bin/cygwin1.dll
#5 0x610ed928 in kill0(int, siginfo_t&) () from /usr/bin/cygwin1.dll
#6 0x610edb02 in raise () from /usr/bin/cygwin1.dll
#7 0x610eddc3 in abort () from /usr/bin/cygwin1.dll
#8 0x5ff8470a in cygstdc++-6!_ZN9__gnu_cxx27__verbose_terminate_handlerEv () from /usr/bin/cygstdc++-6.dll
#9 0x5ff7dcd9 in cygstdc++-6!_ZN10__cxxabiv111__terminateEPFvvE () from /usr/bin/cygstdc++-6.dll
#10 0x5ffd8a00 in cygstdc++-6!_ZSt9terminatev () from /usr/bin/cygstdc++-6.dll
#11 0x5ffde822 in cygstdc++-6!.cxa_throw () from /usr/bin/cygstdc++-6.dll
#12 0x00401790 in foo::~foo() ()
#13 0x004011ba in main ()
(gdb)
Stefan
Back to de.comp.lang.iso-c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Exception mit Durchfall? Edzard Egberts <news@edzeg.net> - 2016-11-18 14:23 +0100
Re: Exception mit Durchfall? Stefan Reuther <stefan.news@arcor.de> - 2016-11-20 11:18 +0100
Re: Exception mit Durchfall? Edzard Egberts <news@edzeg.net> - 2016-11-23 13:11 +0100
Re: Exception mit Durchfall? Stefan Reuther <stefan.news@arcor.de> - 2016-11-24 19:15 +0100
Re: Exception mit Durchfall? Edzard Egberts <news@edzeg.net> - 2016-11-25 08:11 +0100
Re: Exception mit Durchfall? Stefan Reuther <stefan.news@arcor.de> - 2016-11-25 18:07 +0100
Re: Exception mit Durchfall? Edzard Egberts <news@edzeg.net> - 2016-11-28 08:21 +0100
Re: Exception mit Durchfall? Stefan Reuther <stefan.news@arcor.de> - 2016-11-28 17:49 +0100
csiph-web