It looks like __thiscall is now the default calling convention for member functions (where possible) for win32 targets. This seems to have broken exception cleanup. This seg faults when executed (and compiled by mingw-32): =============== struct except { virtual ~except() {} }; int main() { try { throw except(); } catch(except) { } } =============== The seg fault occurs after the catch block is exited, and except::~except() is called by the runtime. I think __gxx_exception_cleanup (in libstdc++-v3/libsupc++/eh_throw.cc) is still trying to call except::~except() using the old calling convention, resulting in a seg fault on any access to 'this'. -Chris
This badly requires a target maintainer.
Doesn't reproduce on Cygwin, and I don't have a current mingw cross compiler handy. It would be best if Kai can look at this as I'm up to my neck in ada at the moment, if he hasn't found time in the next four or five days I'll try and investigate.
Well, this seems to be caused by member exceptionDestructor in __cxa_exception structure. As a destructor has also __thiscall convention, we need to specify it here for 32-bit Windows target. I am just about to test a patch for it.
Author: ktietz Date: Mon Dec 12 13:29:10 2011 New Revision: 182238 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182238 Log: Correct bug-number in ChangeLog. PR libstdc++/51135 * libsupc++/cxxabi.h (__cxxabi_dtor_type): New type. (__cxa_throw): Use it for destructor-argument. * libsupc++/eh_throw.cc (__cxa_throw): Likewise. * libsupc++/unwind-cxx.h (__cxa_exception): Change type of member exceptionDestructor to __cxxabi_dtor_type. * config/os/mingw32-w64/os_defines.h (_GLIBCXX_USE_THISCALL_ON_DTOR): Define. (__cxa_dtor_type): Declare target secific type variant. * config/os/mingw32/os_defines.h: Likewise. Modified: trunk/libstdc++-v3/ChangeLog
Fixed at revision 182237.
Author: paolo Date: Mon Dec 12 17:34:19 2011 New Revision: 182250 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182250 Log: 2011-12-12 Paolo Carlini <paolo.carlini@oracle.com> Revert: 2011-12-12 Kai Tietz <ktietz@redhat.com> PR libstdc++/51135 * libsupc++/cxxabi.h (__cxa_dtor_type): New type. (__cxa_throw): Use it for destructor-argument. * libsupc++/eh_throw.cc (__cxa_throw): Likewise. * libsupc++/unwind-cxx.h (__cxa_exception): Change type of member exceptionDestructor to __cxa_dtor_type. * config/os/mingw32-w64/os_defines.h (_GLIBCXX_USE_THISCALL_ON_DTOR): Define. (__cxa_dtor_type): Declare target secific type variant. * config/os/mingw32/os_defines.h: Likewise. Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/config/os/mingw32-w64/os_defines.h trunk/libstdc++-v3/config/os/mingw32/os_defines.h trunk/libstdc++-v3/libsupc++/cxxabi.h trunk/libstdc++-v3/libsupc++/eh_throw.cc trunk/libstdc++-v3/libsupc++/unwind-cxx.h
Patch reverted.
Author: ktietz Date: Fri Dec 16 18:43:06 2011 New Revision: 182410 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182410 Log: PR libstdc++/51135 * libsupc++/unwind-cxx.h (__cxa_exception): Mark exceptionDestructor by _GLIBCXX_CDTOR_CALLABI. * libsupc++/eh_throw.cc (__cxa_throw): Mark destructor function argument by _GLIBCXX_CDTOR_CALLABI. * libsupc++/cxxabi.h (__cxa_throw): Likewise. (_GLIBCXX_CDTOR_CALLABI): Add empty default definition. * config/os/mingw32-w64/os_defines.h (_GLIBCXX_CDTOR_CALLABI): Define for IA-32 target as __thiscall. * config/os/mingw32/os_defines.h (_GLIBCXX_CDTOR_CALLABI): Likewise. Modified: trunk/libstdc++-v3/config/os/mingw32-w64/os_defines.h trunk/libstdc++-v3/config/os/mingw32/os_defines.h trunk/libstdc++-v3/libsupc++/cxxabi.h trunk/libstdc++-v3/libsupc++/eh_throw.cc trunk/libstdc++-v3/libsupc++/unwind-cxx.h
Fixed at revision 182410.