This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Exceptions are not catched from DLL


Hi all!
I met such a problem: I've been building MinGW with --disable-shared, and
everything went well untill I understood that exceptions from DLL aren't
catched in the main program.
Example. The program terminates with message: terminate called after
throwing an instance of 'int
DLL:
void func() {throw 1;}

MAIN:
void func();
int main() {
   try {
      func();
   } catch ( ... ) {
   }
}

If the implementation of the func() is in the static library - it works
fine.

I rebuilt MinGW with --enable-shared --enable-static. It solved the problem
above. But another problem appeared.
When using std::mutex or std::thread or anything from stdthreads, the
program terminates with SIGSEGV.
Backtrace:
Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
(gdb) backtrace
#0  0x00000000 in ?? ()
#1  0x00401688 in __gthread_cond_timedwait
(__cond=0x22fec4,__mutex=0x22fed4, __abs_timeout=0x22fe10)
    at
c:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.6.2/../../../../include/c++/4.6.2/i686-pc-mingw32/bits/gthr-default.h:853
#2  0x004053b6 in
std::condition_variable::__wait_until_impl<std::chrono::system_clock,
std::chrono::duration<long long, std::ratio<1ll, 1000000000ll> > >
(this=0x22fec4, __lock=..., __atime=...)
    at
c:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.6.2/../../../../include/c++/4.6.2/condition_variable:158
#3  0x0040531b in
std::condition_variable::wait_until<std::chrono::duration<long long,
std::ratio<1ll, 1000000000ll> > > (this=0x22fec4,
__lock=...,__atime=...)
    at
c:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.6.2/../../../../include/c++/4.6.2/condition_variable:95
#4  0x0040542a in std::condition_variable::wait_for<long long,
std::ratio<1ll, 1
000ll> > (this=0x22fec4, __lock=..., __rtime=...)
    at
c:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.6.2/../../../../include/c++/4.6.2/condition_variable:127
#5  0x004019ae in _fu3___ZSt4cout () at thtest.cpp:12


MinGW configured with:

../gcc-4.6.2/configure \
   --prefix=/mingw \
   --host=i686-pc-mingw32 \
   --build=i686-pc-mingw32 \
   --target=i686-pc-mingw32 \
   --enable-languages=c,c++ \
   --with-tune=generic \
   --with-host-libstdcxx=-lstdc++ \
   --enable-shared \
   --enable-static \
   --enable-libgomp \
   --enable-lto \
   --enable-cloog-backend=isl \
   --enable-checking=release \
   --enable-fully-dynamic-string \
   --enable-threads=posix \
   --disable-libstdcxx-pch \
   --enable-libstdcxx-debug \
   --disable-bootstrap \
   --enable-sjlj-exceptions \
   --disable-win32-registry \
   --disable-nls \
   --disable-werror \
   --with-gmp=/libs \
   --with-mpfr=/libs \
   --with-mpc=/libs \
   --with-ppl=/libs \
   --with-cloog=/libs \
   --with-libiconv-prefix=/libs \
   --with-libexpat-prefix=/libs
Thread model: posix
gcc version 4.6.2 (prerelease)


Patch from: http://sourceforge.net/projects/mingw-w64/files/Toolchain%20sources/Personal%20Builds/rubenvb/gcc-4.6.2-stdthread_rubenvb.tar.lzma/download
 - is applyed.


Any ideas?


Thanks.
   niXman.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]