Strange problem with exceptions

Denis Perchine dyp@perchine.com
Wed Nov 1 23:51:00 GMT 2000


Hello,

I have a program which sends mails. Quite easy task...
But I have very strange trouble... If connection to SMTP server
fails it tries to reconnect. But when SMTP server is down in the middle
of sending I get the following error:

Program received signal SIGABRT, Aborted.
0x400a02d1 in kill () from /lib/libc.so.6
(gdb) bt
#0  0x400a02d1 in kill () from /lib/libc.so.6
#1  0x4009ff6c in raise () from /lib/libc.so.6
#2  0x400a176b in abort () from /lib/libc.so.6
#3  0x4004cfeb in __default_terminate () from 
/usr/lib/libstdc++-libc6.1-2.so.3
#4  0x4004dfe0 in terminate () from /usr/lib/libstdc++-libc6.1-2.so.3
#5  0x804a2ba in sendMailEx (from=@0xbffff944, to=@0xbffff95c,
    subject=@0xbffff974, header=@0xbffff98c, body=@0xbffff9a4,
    realfrom=@0xbffff9bc, realto=@0xbffff9d4) at tools.cc:318
#6  0x8049766 in main () at main.cpp:33

You would say that it is a good idea to catch exceptions... I would agree 
with you if I did not do so...

-- tools.cc ---
306:  for (int i=1;; i++) {
307:    try {
308:      SMTPConnection smtp("localhost");
309:      smtp.setFrom(fe);
310:      smtp.addTo(te);
311:      smtp.setData(s);
312:      break;
313:    } catch (ISocketException &x) {
314:      fprintf(stderr, "SendMail: ISocketException: %s", 
x.message().c_str());
315:    } catch (IException &x) {
316:      fprintf(stderr, x.message().c_str());
317:    } catch (...) {
318:      fprintf(stderr, "Unknown exception");
319:    }
320:    fprintf(stderr, "SendMail failed. Will try to reconnect. Try: %d.", 
i);
321:    sleep(5);
322:  }

Maybe there are some other tricks, but I can not catch anything else...

Here is main program:

--- main.cpp ---
23: void sigpipehdl(int n) {
24:   fprintf(stderr, "SIGPIPE catched\n");
25: }
26:
27: int main() {
28:   try {
29:     signal(SIGPIPE, sigpipehdl);
30:
31:     for (;;) {
32:       try {
33:         sendMailEx("dyp@perchine.com", "dyp@perchine.com",
34:            "Test mail", "", "Just a test mail\nDYP\n",
35:            "dyp@perchine.com", "dyp@perchine.com");
36:       } catch (IException &x) {
37:         fprintf(stderr, x.message().c_str());
38:       } catch (...) {
39:         fprintf(stderr, "Unknown exception");
40:       }
41:     }
42:   } catch (IException &x) {
43:     fprintf(stderr, x.message().c_str());
44:   } catch (...) {
45:     fprintf(stderr, "Unknown exception");
46:   }
47: }

For me it seems like compiler bug... Possible bug...
Platform: Linux 2.4.0test9, PIII, gcc 2.95.2 (the same with the latest CVS), 
glibc 2.1.3

All compiled with:-DHAVE_CONFIG_H -I. -I. -I..     -Wall -g3
Linked with: -g3 -lm

-- 
Sincerely Yours,
Denis Perchine

----------------------------------
E-Mail: dyp@perchine.com
HomePage: http://www.perchine.com/dyp/
FidoNet: 2:5000/120.5
----------------------------------


More information about the Gcc mailing list