[Bug libstdc++/40841] Application segfaults when throwing an exception that destroys an fstream

hjl dot tools at gmail dot com gcc-bugzilla@gcc.gnu.org
Fri Jul 24 01:53:00 GMT 2009

------- Comment #6 from hjl dot tools at gmail dot com  2009-07-24 01:52 -------
It works for me on RHEL 4 with gcc 4.4.1:

[hjl@gnu-14 tmp]$ cat foo.cc
#include <fstream>

using namespace std;

void f(const char * filename)
 ifstream is;
 throw 2;

int main()
 try {
 } catch(int e) {
[hjl@gnu-14 tmp]$ /usr/gcc-4.4/bin/g++ foo.cc -Wl,-rpath,/usr/gcc-4.4/lib
[hjl@gnu-14 tmp]$ ldd a.out
        linux-gate.so.1 =>  (0xa000000000000000)
        libstdc++.so.6 => /usr/gcc-4.4/lib/libstdc++.so.6 (0x2000000000044000)
        libm.so.6.1 => /lib/tls/libm.so.6.1 (0x2000000000240000)
        libgcc_s.so.1 => /usr/gcc-4.4/lib/libgcc_s.so.1 (0x20000000002fc000)
        libunwind.so.7 => /usr/gcc-4.4/lib/libunwind.so.7 (0x2000000000330000)
        libc.so.6.1 => /lib/tls/libc.so.6.1 (0x200000000035c000)
        /lib/ld-linux-ia64.so.2 (0x2000000000000000)
[hjl@gnu-14 tmp]$ ./a.out
[hjl@gnu-14 tmp]$ /usr/gcc-4.4/bin/g++ -v
Using built-in specs.
Target: ia64-unknown-linux-gnu
Configured with: /net/gnu-13/export/gnu/src/gcc-4.4/gcc/configure
--enable-clocale=gnu --with-system-zlib --enable-checking=assert
--with-demangler-in-ld --enable-shared --enable-threads=posix --enable-haifa
--prefix=/usr/gcc-4.4 --with-local-prefix=/usr/local
Thread model: posix
gcc version 4.4.1 (GCC)
[hjl@gnu-14 tmp]$ ld -V
GNU ld (Linux/GNU Binutils)
  Supported emulations:
[hjl@gnu-14 tmp]$


hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
                 CC|                            |hjl dot tools at gmail dot
                   |                            |com


More information about the Gcc-bugs mailing list