public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/45209]  New: coredump in exception handling (gcc44, FreeBSD 7.2)
@ 2010-08-06 13:13 skylanderr at gmail dot com
  2010-08-06 13:14 ` [Bug c++/45209] " skylanderr at gmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: skylanderr at gmail dot com @ 2010-08-06 13:13 UTC (permalink / raw)
  To: gcc-bugs

Hello,

I have coredump for exception handling in a c++ program using dynamic library. 
I wrote the minimal application using dlopen to load a libtest_so.so and
execute functions in so with dlsym. In the libtest_so.so I throw an exception
and try to catch it. 

Source code:
1) main application test_exception (test.cpp)  

#include <cstdio>
#include <dlfcn.h>

typedef void (*TFuncVoid)();

int main() {
    void* testlib = dlopen("./libtest_so.so", RTLD_NOW | RTLD_GLOBAL);

    TFuncVoid FFunc = 0;
    FFunc = TFuncVoid(dlsym(testlib, "ThrowCatchException"));
    if (FFunc) {
        try {
            FFunc();
        } catch (...) {
            printf("Catched in test.cpp. \n");
        }
    }

    return 0;
}

2) library libtest_so.so (test_so.cpp)

#include <cstdio>

extern "C" void ThrowCatchException() {
    try {
        throw 5;
    } catch (int) {
        printf("catch (int): la-la-la \n");
    } catch (...) {
        printf("catch (...): la-la-la \n");
    }
}

3) Commands for compiling the application:
g++44 -g -Wall -fPIC -fexceptions
-DNATIVE_INCLUDE_PATH="/usr/local/lib/gcc44/include/c++/" -I<include_path_1>
-I<include_path_2> -o CMakeFiles/test_exception.dir/test.cpp.o -c
<path_to_src>/test/test.cpp

g++44 -nostdlib /usr/lib/crt1.o /usr/lib/crti.o
/usr/local/lib/gcc44/gcc/x86_64-portbld-freebsd7.2/4.4.1/crtbegin.o -g -Wall
-fPIC -fexceptions -DNATIVE_INCLUDE_PATH="/usr/local/lib/gcc44/include/c++/"
-Wl,-E  CMakeFiles/test_exception.dir/test.cpp.o  -o test_exception  
/usr/local/lib/gcc44/gcc/x86_64-portbld-freebsd7.2/4.4.1/../../../libsupc++.a
/usr/local/lib/gcc44/gcc/x86_64-portbld-freebsd7.2/4.4.1/libgcc.a
/usr/local/lib/gcc44/gcc/x86_64-portbld-freebsd7.2/4.4.1/libgcc_eh.a -lc -lm
/usr/local/lib/gcc44/gcc/x86_64-portbld-freebsd7.2/4.4.1/crtend.o
/usr/lib/crtn.o

4) Commands for compiling the library:
g++44 -g -Wall -fPIC -fexceptions
-DNATIVE_INCLUDE_PATH="/usr/local/lib/gcc44/include/c++/" -I<include_path_1>
-I<include_path_2> -o CMakeFiles/test_so.dir/test_so.cpp.o -c
<path_to_src>/test_so.cpp

g++44 -fPIC -g -Wall -fexceptions
-DNATIVE_INCLUDE_PATH="/usr/local/lib/gcc44/include/c++/" -shared
-Wl,-soname,libtest_so.so -o libtest_so.so CMakeFiles/test_so.dir/test_so.cpp.o 

4) correct output (command ./test_exception):
"catch (int): la-la-la"

5) wrong result (command ./test_exception):
terminate called after throwing an instance of 'int'
Abort trap (core dumped)

6) my gcc configuration info (g++44 -v)
Using built-in specs.
Target: x86_64-portbld-freebsd7.2
Configured with: ./../gcc-4.4-20090616/configure --disable-nls
--with-system-zlib --with-libiconv-prefix=/usr/local --with-gmp=/usr/local
--program-suffix=44 --libdir=/usr/local/lib/gcc44
--libexecdir=/usr/local/libexec/gcc44
--with-gxx-include-dir=/usr/local/lib/gcc44/include/c++/ --disable-libgcj
--prefix=/usr/local --mandir=/usr/local/man --infodir=/usr/local/info/gcc44
--build=x86_64-portbld-freebsd7.2
Thread model: posix
gcc version 4.4.1 20090616 (prerelease) (GCC)


-- 
           Summary: coredump in exception handling (gcc44, FreeBSD 7.2)
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: skylanderr at gmail dot com
  GCC host triplet: x86_64-unknown-freebsd7.2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45209


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/45209] coredump in exception handling (gcc44, FreeBSD 7.2)
  2010-08-06 13:13 [Bug c++/45209] New: coredump in exception handling (gcc44, FreeBSD 7.2) skylanderr at gmail dot com
@ 2010-08-06 13:14 ` skylanderr at gmail dot com
  2010-08-06 13:15 ` skylanderr at gmail dot com
  2010-08-06 14:08 ` [Bug target/45209] " rguenth at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: skylanderr at gmail dot com @ 2010-08-06 13:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from skylanderr at gmail dot com  2010-08-06 13:14 -------
Created an attachment (id=21422)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21422&action=view)
the preprocessed file for tha application


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45209


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/45209] coredump in exception handling (gcc44, FreeBSD 7.2)
  2010-08-06 13:13 [Bug c++/45209] New: coredump in exception handling (gcc44, FreeBSD 7.2) skylanderr at gmail dot com
  2010-08-06 13:14 ` [Bug c++/45209] " skylanderr at gmail dot com
@ 2010-08-06 13:15 ` skylanderr at gmail dot com
  2010-08-06 14:08 ` [Bug target/45209] " rguenth at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: skylanderr at gmail dot com @ 2010-08-06 13:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from skylanderr at gmail dot com  2010-08-06 13:15 -------
Created an attachment (id=21423)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21423&action=view)
the preprocessed file for the library


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45209


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/45209] coredump in exception handling (gcc44, FreeBSD 7.2)
  2010-08-06 13:13 [Bug c++/45209] New: coredump in exception handling (gcc44, FreeBSD 7.2) skylanderr at gmail dot com
  2010-08-06 13:14 ` [Bug c++/45209] " skylanderr at gmail dot com
  2010-08-06 13:15 ` skylanderr at gmail dot com
@ 2010-08-06 14:08 ` rguenth at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-08-06 14:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2010-08-06 14:08 -------
Works on x86_64-linux.  I suspect that linking libgcc and libgcc_eh statically
causes the problem for you as I can reproduce the segfault when linking
the whole test application statically.  Thus, this sounds like an installation
problem on your side.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |target
 GCC target triplet|                            |x86_64-unknown-freebsd7.2
            Version|unknown                     |4.4.1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45209


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-08-06 14:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-06 13:13 [Bug c++/45209] New: coredump in exception handling (gcc44, FreeBSD 7.2) skylanderr at gmail dot com
2010-08-06 13:14 ` [Bug c++/45209] " skylanderr at gmail dot com
2010-08-06 13:15 ` skylanderr at gmail dot com
2010-08-06 14:08 ` [Bug target/45209] " rguenth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).