[patch PR libstdc++/51135]: Fix [4.7 Regression] SIGSEGV during exception cleanup on win32

Kai Tietz ktietz70@googlemail.com
Mon Dec 12 13:07:00 GMT 2011


2011/12/12 Paolo Carlini <paolo.carlini@oracle.com>:
> On 12/12/2011 01:19 PM, Kai Tietz wrote:
>>
>> Well, this is mainly caused by different feature-set of runtimes. We
>> could solve things here also by probing for specific runtimes and so
>> using just on configure tree.
>
> Ah, thus, it's *not* true that mingw32, at variance with mingw32-w64, is
> only used for i386? Anyway, as I said already, in the config files you can
> check all the macros you like ;)
>
> Paolo.

No, mingw32 (the mingw.org variant) is used for IA 32-bit  Mingw-w64
allows additionally to do a build in compatible-mode to mingw.org (by
using -pc- as vendor-key in triplet), so there is actually also a
variant for x64 present for it, too.

For multilib it is required to check in target's config for the __i386__ target.

So updated patch is:

ChangeLog

2011-12-12  Kai Tietz  <ktietz@redhat.com>

	PR libstdc++/511135
	* 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.

Index: gcc/libstdc++-v3/libsupc++/cxxabi.h
===================================================================
--- gcc.orig/libstdc++-v3/libsupc++/cxxabi.h
+++ gcc/libstdc++-v3/libsupc++/cxxabi.h
@@ -51,6 +51,10 @@
 #include <bits/cxxabi_tweaks.h>
 #include <bits/cxxabi_forced.h>

+#ifndef _GLIBCXX_USE_THISCALL_ON_DTOR
+typedef void (*__cxa_dtor_type) (void *);
+#endif
+
 #ifdef __cplusplus
 namespace __cxxabiv1
 {
@@ -596,7 +600,7 @@ namespace __cxxabiv1

   // Throw the exception.
   void
-  __cxa_throw(void*, std::type_info*, void (*) (void *))
+  __cxa_throw(void*, std::type_info*, __cxa_dtor_type)
   __attribute__((__noreturn__));

   // Used to implement exception handlers.
Index: gcc/libstdc++-v3/libsupc++/eh_throw.cc
===================================================================
--- gcc.orig/libstdc++-v3/libsupc++/eh_throw.cc
+++ gcc/libstdc++-v3/libsupc++/eh_throw.cc
@@ -58,8 +58,8 @@ __gxx_exception_cleanup (_Unwind_Reason_


 extern "C" void
-__cxxabiv1::__cxa_throw (void *obj, std::type_info *tinfo,
-			 void (*dest) (void *))
+__cxxabiv1::__cxa_throw (void *obj, std::type_info *tinfo,
+			 __cxa_dtor_type dest)
 {
   // Definitely a primary.
   __cxa_refcounted_exception *header
Index: gcc/libstdc++-v3/libsupc++/unwind-cxx.h
===================================================================
--- gcc.orig/libstdc++-v3/libsupc++/unwind-cxx.h
+++ gcc/libstdc++-v3/libsupc++/unwind-cxx.h
@@ -51,7 +51,7 @@ struct __cxa_exception
 {
   // Manage the exception object itself.
   std::type_info *exceptionType;
-  void (*exceptionDestructor)(void *);
+  __cxa_dtor_type exceptionDestructor;

   // The C++ standard has entertaining rules wrt calling set_terminate
   // and set_unexpected in the middle of the exception cleanup process.
Index: gcc/libstdc++-v3/config/os/mingw32-w64/os_defines.h
===================================================================
--- gcc.orig/libstdc++-v3/config/os/mingw32-w64/os_defines.h
+++ gcc/libstdc++-v3/config/os/mingw32-w64/os_defines.h
@@ -65,4 +65,9 @@
 // ioctlsocket function doesn't work for normal file-descriptors.
 #define _GLIBCXX_NO_IOCTL 1

+#if defined (__i386__)
+#define _GLIBCXX_USE_THISCALL_ON_DTOR 1
+typedef void (__thiscall *__cxa_dtor_type) (void *);
+#endif
+
 #endif
Index: gcc/libstdc++-v3/config/os/mingw32/os_defines.h
===================================================================
--- gcc.orig/libstdc++-v3/config/os/mingw32/os_defines.h
+++ gcc/libstdc++-v3/config/os/mingw32/os_defines.h
@@ -65,4 +65,9 @@
 // ioctlsocket function doesn't work for normal file-descriptors.
 #define _GLIBCXX_NO_IOCTL 1

+#if defined (__i386__)
+#define _GLIBCXX_USE_THISCALL_ON_DTOR 1
+typedef void (__thiscall *__cxa_dtor_type) (void *);
+#endif
+
 #endif

(retested)

Regards,
Kai



More information about the Gcc-patches mailing list