X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1C745385C8B1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1597697414; bh=BfW4Fc14BTUdcmcz5u2JVJGi7xETqa3h/3FwrN0+Vhc=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=NVHbe3HaDSfApCgCLjNWPNFAjv2uo2MGWbsDFZobuKHrrvPpZUV3ydaEtY6bBdX4p jyahpYQGqmq0vi9VvOxnw4ynSLmiwKgqF2J++s/eu7CzBooZLKhjQc7VWC+MyRIB31 pzw0cEjdx2jRy2Al8/JrOptV+av6u5ms6V58Rayg= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org AC50F3857C43 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AYkF+DiEvZjSy0JdJJiCEqj5+OJBMl3a4Xz18wLNAj+L/Q8pS4ttML+Nr47hYGN8zSuR7MjzIuWGbTYVI/xsb0yYVITQelrdpM/Y1xFUGNuCEtWLsPugh5IQCk/mlogVGq1mkwCcfrhPuS0S++KAW/kyexImj5Cd5ATr1mZ3mTbxa5MDcKEGavE4qy+qFEVIkVxCC5MDS1ra+t4jyzErkCX2lBFyPoiQjI8bU2qxpm2MsN381HEFs7jALJyOCVnC9W8opFu/3z3THHdwT0KjCjAzzRBrPZwruxWEsr555dXTMQLzELmLQKCbQvsYFakoPJlvu5OIAvRsoPXAEAKLEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yfA/Bl060xIxQYe7grEIkmRQ7FVTLWqlxuPBW8KV70g=; b=Kv4MQLV+92NzFLsYoYyGwbIAfTOp7kxRjU8F2MN0OKDDAfSXs1zsDvtLjEjDfyQFw5hnI6H7YvDZpUewHVnkpO/95sZRGOxXOIzGUGQvLGIB1+6AjVH5Gmp4PKCUh6rm5ZQBL9p213reTkG8MKLYIcktvbtfeMqeSGqU5RdC3AFWEovQQDNMUVydZvHq+28EBer2+oQbZ9wQLfES/UM4Gmp4yfVK+GHoGHPsFGUiEfvCrUHKZPTK4S04yE/C7yIrOp/Exx975NzTwDH6Gt0fp9uI4u4Vw3Yp0JG2Y4JnVYPEC9u1v8kEEAc6tTicdLFyNu7iCKqcxXeIMmYQYZ4cxA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cornell.edu; dmarc=pass action=none header.from=cornell.edu; dkim=pass header.d=cornell.edu; arc=none Subject: Re: [Attn: gcc maintainers] Re: unhandled C++ exceptions not propagating To: cygwin AT cygwin DOT com References: <20200816125306 DOT 60dc246baf63d7f9fba60611 AT nifty DOT ne DOT jp> <6c27d8d6-876a-6c09-bccd-a9123400cfdb AT cornell DOT edu> <20200816225221 DOT d7c41334927c9766d6e26415 AT nifty DOT ne DOT jp> <84a15cee-d772-4422-9cf0-1cec8d188cae AT cornell DOT edu> <70f23307-6aaf-db8a-103e-81303350ffec AT cornell DOT edu> <9525d8c2-74af-5c04-8a04-d84df4b1f2ef AT cornell DOT edu> <20200817181359 DOT GI3272 AT calimero DOT vinschen DOT de> <8338a995-1bab-9489-55c2-b6eb2e0ac844 AT cornell DOT edu> <437eecde-22ea-2777-3062-a0f43e7dbc70 AT cornell DOT edu> Message-ID: <27077c89-c826-2e5d-fcbe-1aa64fca4690@cornell.edu> Date: Mon, 17 Aug 2020 16:50:03 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 In-Reply-To: <437eecde-22ea-2777-3062-a0f43e7dbc70@cornell.edu> Content-Language: en-US X-ClientProxiedBy: BL0PR0102CA0072.prod.exchangelabs.com (2603:10b6:208:25::49) To MN2PR04MB6176.namprd04.prod.outlook.com (2603:10b6:208:e3::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [IPv6:2604:6000:b407:7f00:6ddb:1b9b:deef:3580] (2604:6000:b407:7f00:6ddb:1b9b:deef:3580) by BL0PR0102CA0072.prod.exchangelabs.com (2603:10b6:208:25::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.16 via Frontend Transport; Mon, 17 Aug 2020 20:50:04 +0000 X-Originating-IP: [2604:6000:b407:7f00:6ddb:1b9b:deef:3580] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ad272ebf-0808-4396-3381-08d842ef1ea0 X-MS-TrafficTypeDiagnostic: MN2PR04MB6223: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rZjt7EqQ72jAZBKzHqtbngXvcaMFXTWWXoY0zDPuYeNxmJlJaqK8U64V0B6M1o6K5PPCodkh7PzfgBbw3qEi5ijhgqnlDk8FmEGDUh6Buo+EZgE24JywjM44359GVGip+n88YhEIaBFI5kahIIhF7ifFZbFq+5Vvf7pv7WNmtj1lhuPauGj5xZaoizs/eNrvPKBvBqZEzdcRXzTyJ6fcfYI2wpeNo7v2wLnNQgnwa+i9G9Ro50A6Unk8qnYx9BhqkC1ereRPgcbt47pCn3/7nIjYjjqbk9hKFGtgtoySDUp3wGApT6bC8thJQnQPUlyuhk0B6B5Nc8xRKcXt6095CNwFvz1Dj0XOU3jaGUm+RzKYBdzrrt+GmBAWM16eZlFA X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR04MB6176.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(39860400002)(346002)(376002)(136003)(396003)(31686004)(66476007)(8676002)(316002)(16526019)(31696002)(66556008)(6486002)(86362001)(6916009)(786003)(66946007)(53546011)(75432002)(36756003)(2616005)(5660300002)(186003)(2906002)(8936002)(478600001)(4326008)(52116002)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: zyYy6iJvvup63iJmDHjupcPwLMs81lPLzBLUZbNjOP/xfFuo0iuJTs8ZbNVX/nVHoaI7mH2kvu2HeF7D9IjAcjTR8RpQlz5Slf4DJyS5X7beMLHgYerGFtIV8REQ12PHXKscSLEuOW9/auruzVoh5hNNX54qXyOez+m/+JW2fk0B2LBFitI+F4N2kudKZLNjj50oh94951vd+UAKVs/XUIrkv+uBJAYeF5IQjghU7Qd8QqBiqKc/SRshYWUpwB9QN5q0tVHSA8CuReE6tDNG1cVQ2Dk8mpxXIU1k+1JE6mSoo6trCKyIJWdZWSLk7IgoOGam8SxPE8kNlrUxzM4XD/Ei7ib8ORK/dVB0HUbLkovKMqhox7eCNdtqthpfEqxMfWJzUN9DTVWUdUlhz3NxBW5SCjeNtFhqUGlbEvbNAsNoeG4dblEIzZIs0ux17piQnhDHusu9UQIprLUe/4EO9Q65V9xUCErMZUKjjPzDx6t4VUhA/i8sFGPIfdFH5bEX8YjOYR1cEdwSq1aH7fyb5dWQ2aCpD6iGv1iKM8Wutu3iiOB8EzE6wtTrOo5YzmZ8mlRpfo407kiCkDJhiXW6zs8RbmzPFcmahFkmg7yxMng7Q/XTdW2GaUO4nXWWwC+3CCRntxXaMAkfq3NYmsAeO2+xrqh6ZDtnJult+mZ6johEmP8w1EAsXVkOde5mQrJlyHS9+2NxrM7G0e0FAuRWDw== X-OriginatorOrg: cornell.edu X-MS-Exchange-CrossTenant-Network-Message-Id: ad272ebf-0808-4396-3381-08d842ef1ea0 X-MS-Exchange-CrossTenant-AuthSource: MN2PR04MB6176.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2020 20:50:05.2307 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5d7e4366-1b9b-45cf-8e79-b14b27df46e1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Fsbja9d0avtLA03FGr9teNt81a7M0Ce++KWCD2B0gtWv7qmrfS2Yczd04s9WcSch8tQZxAN2QW1/tuZYpAZFfw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR04MB6223 X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, KAM_DMARC_STATUS, MSGID_FROM_MTA_HEADER, NICE_REPLY_A, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Ken Brown via Cygwin Reply-To: Ken Brown Cc: David McFarland Content-Type: text/plain; charset="windows-1252"; Format="flowed" Errors-To: cygwin-bounces AT cygwin DOT com Sender: "Cygwin" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id 07HKodKD008420 On 8/17/2020 4:40 PM, Ken Brown via Cygwin wrote: > On 8/17/2020 3:06 PM, Ken Brown via Cygwin wrote: >> On 8/17/2020 2:13 PM, Corinna Vinschen wrote: >>> On Aug 17 13:36, Ken Brown via Cygwin wrote: >>>> On 8/16/2020 6:38 PM, Ken Brown via Cygwin wrote: >>>>> One further comment, and then I'll shut up >>>> >>>> I lied. >>> >>> ...which is ok. >>> >>>>> and leave it to people who know what they're talking about: In the >>>>> 64-bit case, the function _Unwind_RaiseException in libgcc/unwind-seh.c >>>>> gets called, and it calls the Win32 function RaiseException as follows: >>>>> >>>>>     RaiseException (STATUS_GCC_THROW, 0, 1, (ULONG_PTR *)&exc); >>>>> >>>>> Then the following comment appears: >>>>> >>>>>     /* The exception handler installed in crt0 will continue any GCC >>>>>        exception that reaches there (and isn't marked non-continuable). >>>>>        Returning allows the C++ runtime to call std::terminate.  */ >>>>> >>>>> Apparently this doesn't actually happen. >>>> >>>> I'm beginning to think this is a bug in the Cygwin build of gcc.  The file >>>> unwind-seh.c is compiled on 64-bit Cygwin because __SEH__ is defined.  But >>>> it makes assumptions, such as those in the comment quoted above, that are >>>> not valid on Cygwin. >>>> >>>> In fact, if you look at the main exception handler on Cygwin >>>> (exceptions.cc:626), it is clear that the exception code STATUS_GCC_THROW >>>> does not lead to continuation.  It falls under the default case: >>>> >>>>      default: >>>>        /* If we don't recognize the exception, we have to assume that >>>>      we are doing structured exception handling, and we let >>>>      something else handle it.  */ >>>>        return ExceptionContinueSearch; >>>> >>>> [STATUS_GCC_THROW is 0x20474343, which shows up in the gdb output above as >>>> an unknown target exception.] >>>> >>>> So it seems to me that either Cygwin's exception handler has to learn to >>>> handle the exception codes defined in unwind-seh.c, or else gcc should be >>>> built with __SEH__ undefined. >>>> >>>> JonY, Achim, Corinna, am I missing something? >>> >>> This stuff isn't really my strong point.  IIUC the above comment correctly, >>> we might get away with adding another case to the exception handler switch: >>> >>>    #define STATUS_GCC_THROW 0x20474343 >>>    case STATUS_GCC_THROW: >>>      return ExceptionContinueExecution; >>> >>> Did you try that, by any chance? >> >> No, I didn't.  It might well solve the immediate problem of this bug report. >> But then there are two other exception codes that occur in unwind-seh.c that >> we would also have to deal with: STATUS_GCC_UNWIND    and STATUS_GCC_FORCED. >> Someone would have to look at their uses and figure out what, if anything, >> Cygwin should do with them. > > This isn't an issue after all.  The comment I quoted above refers to all GCC > exceptions, not just STATUS_GCC_THROW.  I'll submit a patch after testing. I've sent the patch. The output of the OP's test case is now the same on 64-bit as on 32-bit: $ ./a terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_S_construct null not valid Aborted (core dumped) Ken -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple