From patchwork Mon Dec 12 11:11:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai Tietz X-Patchwork-Id: 130704 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id C7A57B6F18 for ; Mon, 12 Dec 2011 22:11:36 +1100 (EST) Received: (qmail 23659 invoked by alias); 12 Dec 2011 11:11:31 -0000 Received: (qmail 23645 invoked by uid 22791); 12 Dec 2011 11:11:30 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, TW_CX X-Spam-Check-By: sourceware.org Received: from mail-gx0-f175.google.com (HELO mail-gx0-f175.google.com) (209.85.161.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 12 Dec 2011 11:11:16 +0000 Received: by ggnh1 with SMTP id h1so5543814ggn.20 for ; Mon, 12 Dec 2011 03:11:15 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.89.105 with SMTP id bn9mr2812933obb.65.1323688275369; Mon, 12 Dec 2011 03:11:15 -0800 (PST) Received: by 10.182.154.65 with HTTP; Mon, 12 Dec 2011 03:11:15 -0800 (PST) In-Reply-To: References: Date: Mon, 12 Dec 2011 12:11:15 +0100 Message-ID: Subject: Re: [patch PR libstdc++/51135]: Fix [4.7 Regression] SIGSEGV during exception cleanup on win32 From: Kai Tietz To: Jonathan Wakely Cc: GCC Patches , "libstdc++" X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, so as no other review happend, I changed patch as you suggested. Tested for i686-w64-mingw32, and regression tested for x86_64-unknown-linux-gnu. Ok for apply? Regards, Kai ChangeLog 2011-12-12 Kai Tietz PR libstdc++/511135 * libsupc++/cxxabi.h (__cxxabi_dtor_type): New type. (__cxa_throw): Use it for destructor-argument. * eh_throw.cc (__cxa_throw): Likewise. * unwind-cxx.h (__cxa_exception): Change type of member exceptionDestructor to __cxxabi_dtor_type. Index: gcc/libstdc++-v3/libsupc++/cxxabi.h =================================================================== --- gcc.orig/libstdc++-v3/libsupc++/cxxabi.h +++ gcc/libstdc++-v3/libsupc++/cxxabi.h @@ -51,6 +51,16 @@ #include #include +// On 32-bit IA native windows target is the used calling-convention +// for class-member-functions of kind __thiscall. As destructor is +// also of kind class-member-function, we need to specify for this +// target proper calling-convention on destructor-function-pointer. +#if defined (__MINGW32__) && defined (__i386__) +typedef void (__thiscall *__cxxabi_dtor_type) (void *); +#else +typedef void (*__cxxabi_dtor_type) (void *); +#endif + #ifdef __cplusplus namespace __cxxabiv1 { @@ -596,7 +606,7 @@ namespace __cxxabiv1 // Throw the exception. void - __cxa_throw(void*, std::type_info*, void (*) (void *)) + __cxa_throw(void*, std::type_info*, __cxxabi_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, + __cxxabi_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 *); + __cxxabi_dtor_type exceptionDestructor; // The C++ standard has entertaining rules wrt calling set_terminate // and set_unexpected in the middle of the exception cleanup process.