Bug #2: char* Exception not propogated to caller

Monique Kuo monique_kuo@yahoo.com
Thu Jan 6 07:12:00 GMT 2000


Hello,

I have found a bug re: C++ exceptions not being properly propogated to
the caller.

The same problem exists on both linux and Sun Solaris when I use g++.
However, when I use Sun's CC the problem does not exist.  gcc was built
using the --enable-shared configuration option.

The source code to recreate the problem is in the following file.

The bug is that when the exception "thrown" is simply of type char* the
exception is not propogated outside that method and so the "try ...
catch" structure does not get notification of the exception and the
program core dumps.

This exception "try ... catch" works (i.e., no core dump).when Sun's CC
is used.

(The following output was generated on a linus machine
#uname -a
Linux timestock.jpc.com.tw 2.2.5-15CLEsmp #1 SMP Mon May 3 04:48:56 CST
1999 i686 unknown)

All machine and version info is the same as that specified in a bug I
also submitted today (exception not propogated from a shared library) so
I will not include the .ii and other info here.  I hope that this is not
too inconvenient.  I am sure that you will probably want to reproduce it
yourselves anyway :)

---------------------------------------------------------

tst.cpp  :

#include <iostream.h>
void tstMethod () {
  throw "abc";
}

int main (int argc, char *argv[])
{
  try {
    tstMethod();
  }
  catch (char* c) {
    cout << c << endl;
  }
}

# g++ tst.cpp -o tst.exe

------------------------------------------------------------------------

The program output is: "Aborted (core dumped)".

gdb tst.exe core
GNU gdb 4.17.0.11 with Linux support
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for
details.
This GDB was configured as "i386-redhat-linux"...
Core was generated by `tst.exe'.
Program terminated with signal 6, Aborted.
Reading symbols from /usr/share/chinese/xa+cv/wrap.so...done.
Reading symbols from /usr/lib/libstdc++-libc6.1-2.so.3...done.
Reading symbols from /lib/libm.so.6...done.
Reading symbols from /lib/libc.so.6...done.
Reading symbols from /lib/libdl.so.2...done.
Reading symbols from /lib/ld-linux.so.2...done.
#0  0x400a2111 in __kill ()
(gdb) bt
#0  0x400a2111 in __kill ()
#1  0x400a1d66 in raise (sig=6) at ../sysdeps/posix/raise.c:27
#2  0x400a3447 in abort () at ../sysdeps/generic/abort.c:88
#3  0x40050c5b in __default_terminate ()
#4  0x40050c7c in __terminate ()
#5  0x40051574 in throw_helper (eh=0x40066144, pc=0x4009bcb2,
    my_udata=0xbffff748, offset_p=0xbffff744)
#6  0x4005172c in __throw ()
#7  0x8048a46 in main ()
#8  0x4009bcb3 in __libc_start_main (main=0x8048a34 <main>, argc=1,
    argv=0xbffff824, init=0x8048820 <_init>, fini=0x8048bf4 <_fini>,
    rtld_fini=0x4000a350 <_dl_fini>, stack_end=0xbffff81c)
    at ../sysdeps/generic/libc-start.c:78
------------------------------------------------------------------------------------------------

Thanks in advance for your attention.  Please let me know if there is
more that I can help with :)

Sincerely,

Leslie

--
// Leslie Ruskin
// EMail: Shanti@TheHelm
// http://members.tripod.com/~sattva/
// Jade Pacific Corporation
// 7F #58, Min-Chuan E. Road, Sec 3, Taipei, Taiwan
// TEL: (886)(2)2515-0253 x428   FAX: (886)(2)2504-5078
// U.S.A. Fax (703) 940-5515
// U.S.A. Voice Mail Box 1(661)420-9511


More information about the Gcc-bugs mailing list