delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2020/08/16/10:57:20

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 43C503857C72
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1597589791;
bh=/bp85ncVc2wbLSEcSV8OWvXCA9xhvTfFwBaQ0YRLdNo=;
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=LsvRX7+PL8a+dc34Gfh+o+n9UkxEDhSK9aPYhoEAf+0fbpHGanQiqZHOgibykjyVi
Ejuc8Qruq1qq2Utmixwt2mLB6nNgEJa3w1eEyc1xfQ8ws5VV86C+PJ7EgtiHgtZ1TG
x9XX6tTc3yp4dugyoPUmpEVmsTg4XYDxWn/zDYYk=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D507E3857C4A
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=gJroGBUTK3xy4vKBlmqIXsM+BizY8G4TzTB+VVEUFM2R9DzljVtRzmAE4YX3BI3x9ceyyhGwSZSdShTHjjAEO6I0XmXUfZjz4X9X4+6yYxc3rc0ONtlyqUmwrakluIFiuUjjLvX5mK4pIBjsglc8SutE58EDRtxfW93hNcwO/ZXAr3bQHVhO3ht3qb7VAJ72mumEHhnxrcMZybei9ff6ulYAYyD5H1ZBZnvJfeVyKrQVaC+YxBSOiauT9IE1lCac0MMqo7ekyaopKbIbom+NF9E2oVSCB7QArwFSOC/0rEoj2Oh7ZA3mWBR/iASlk9lqGdnbzDCo8FBTbXEZ3NNvgg==
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=Zwy3gWYUzaBv/1k6js1cqrchezIsFfzgcIROn1u3HUg=;
b=FPcLg1fd1+zRxbnBnjw818FkwpvX8LNvnc8qLM6KozOfs/skm2hfZegoTm9qOew3xGCotLAYJIVCqkw6NRBF9eVEyb4Io4z4m6OjVtrwn/aE3F3kyZmlgJXlI2KsDpHpW6j5ceed+pcV4vlKQKPwVaw0YJXkYdNm0AynIt9P43ittV9Qwpo5IFzpbdY4tZDsQLqQ1+JGEOV4un1Llh/B5xAQm/4eCnctK3UornQRnxb+4PDfCRRKYhf+VyCYq6diO2Xe2gS/8PM5Wz03rOPwtGkbVK5lHNRETu34N8Ec6MgLL6sTPQr7gncgXZmoCtC52icd1mRgtKFgECFdUVApLw==
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: unhandled C++ exceptions not propagating
To: cygwin AT cygwin DOT com
References: <vritk0xzfpk6 DOT fsf AT gmail DOT com>
<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>
Message-ID: <84a15cee-d772-4422-9cf0-1cec8d188cae@cornell.edu>
Date: Sun, 16 Aug 2020 10:56:21 -0400
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101
Thunderbird/68.11.0
In-Reply-To: <20200816225221.d7c41334927c9766d6e26415@nifty.ne.jp>
X-ClientProxiedBy: CH2PR02CA0018.namprd02.prod.outlook.com
(2603:10b6:610:4e::28) To MN2PR04MB6176.namprd04.prod.outlook.com
(2603:10b6:208:e3::13)
MIME-Version: 1.0
X-MS-Exchange-MessageSentRepresentingType: 1
X-Originating-IP: [68.175.129.7]
X-MS-PublicTrafficType: Email
X-MS-Office365-Filtering-Correlation-Id: dde86437-7dfc-489d-2d79-08d841f48b6e
X-MS-TrafficTypeDiagnostic: MN2PR04MB5664:
X-Microsoft-Antispam-PRVS: <MN2PR04MB5664729B47422F0B1404384FD85E0 AT MN2PR04MB5664 DOT namprd04 DOT prod DOT outlook DOT com>
X-MS-Oob-TLC-OOBClassifiers: OLM:3631;
X-MS-Exchange-SenderADCheck: 1
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: gIVR9+WdcUdI4accqY14ajADYMkn2fVlZ29Mb/qVw2fTtFhGLbzNDcxxnLXBwkTwjGq5R2kjKSIXptTkAzFo+pVyuM0mDND1oXQzcNuf102IaiorjtGFpFqqfAy2Ubz0pHDVBU0KllGmwwDrOPuBUIJ+9AaXZAsZ50LIQlIr+0/O0HNEfshFLBpuwz22jTUwJa/418iJ/PIspfiDd+2+HD8QX7hlrIKWXdNuVD4oVc64uLymnxzy21z97Fxwzx41UN7qdlYM6zuvSn3vci2yfeXQayTSTXBoR0YSfrJe+MfF/ayKGgOdvtGgY7syMdWo3pA5Cbz8fRypBFZArh9AkB4CEQectBGSdO/hYBtJybawGk9dYbHpr2yrq88XTYL9TdIKPe29JNJIcbvfGj6vio3W57G5Yt6rfrI11WwyqfmejBh+hl0LcJYDbOU6xJVlVb5Dw5fHYjwGbbEqwAeasA==
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)(376002)(366004)(346002)(396003)(39860400002)(136003)(53546011)(966005)(52116002)(478600001)(2906002)(75432002)(26005)(6916009)(4326008)(186003)(16526019)(31686004)(8936002)(36756003)(6486002)(8676002)(66556008)(66476007)(5660300002)(66946007)(16576012)(66574015)(19627235002)(31696002)(83380400001)(86362001)(956004)(2616005)(786003)(316002)(43740500002);
DIR:OUT; SFP:1102;
X-MS-Exchange-AntiSpam-MessageData: K2pcqeLw9WONx6No8qA0VmLIZaUg2nC0fH/Bn52CA/nmjx5+/W6wWX+o6hGwZOjXEUW/FjXy45oRy9rUdU9MEWEBTUFpCiCozBjc8Q8VDaY+U68RFF2YE4yVyiEWc56BEM5shctAscO9R5GIJvIHcl8l3ApFzE0eQnShXw80RpC093WApIycbJ16CKMpaIdNktnhL77bvVIgZZ1e5JInVPDU4cwO2hGWdUGIeWZobuCqvBHTTMUt+TGz/SsJF9VrGT6M9Grh+0FGWv7efRvhoRhC+s/uI4ALlg4UsHHPscX2bIJ8PLPzV7/W74SVbaOwZr/KBW9sE3waEwN/2D+g1hLgu196FNBeP4aSUXJcFZmdQtq36WCyxPEHNF9XI42MYVAXC3kPXT87MCW+2M3Xaxqk40L9nmqtBRyKzUn1pQIc4ZsokVhb36zUaAkadAQXqjQLUyir3QMXHiQjv7pbq/xcj3vw110AFayUoa6pZF2iIImPBfmC7kSq6wPoGMgAPPSfbL1/5KBVLcevvuKIId3s6Qea5y/Yn5SFLY22r5tSTdJ19SI2UedPx3Hr98bZA+pJuPOF5bCjMOd7sFJggz6mljlNPvwM3N/GQ6SYLMeI30CdwUZNtSJXuICqtAH/wS3zYGj65vOnX9wcdkNkyA==
X-OriginatorOrg: cornell.edu
X-MS-Exchange-CrossTenant-Network-Message-Id: dde86437-7dfc-489d-2d79-08d841f48b6e
X-MS-Exchange-CrossTenant-AuthSource: MN2PR04MB6176.namprd04.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2020 14:56:24.1393 (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: njBH63g3TlfCFCDc66gjrRfxwYh8CI+Nd6g4ryJwkkM+Wu/idMG81ltLaeEhm68D14NOeHxl5OnSJO5RWOTKFw==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR04MB5664
X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, JMQ_SPF_NEUTRAL,
MSGID_FROM_MTA_HEADER, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,
SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham 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
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Ken Brown via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Ken Brown <kbrown AT cornell DOT edu>
Cc: David McFarland <corngood AT gmail DOT com>
Errors-To: cygwin-bounces AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces AT cygwin DOT com>

On 8/16/2020 9:52 AM, Takashi Yano via Cygwin wrote:
> On Sun, 16 Aug 2020 09:21:24 -0400
> Ken Brown via Cygwin <cygwin AT cygwin DOT com> wrote:
>> On 8/15/2020 11:53 PM, Takashi Yano via Cygwin wrote:
>>> On Sat, 15 Aug 2020 20:38:01 -0300
>>> David McFarland via Cygwin <cygwin AT cygwin DOT com> wrote:
>>>>
>>>> I was just debugging a c++ app (b2 build system from boost), and noticed
>>>> that it would appear to exit unexpectedly without an error.  This turned
>>>> out to be when an unhandled C++ exception was thrown.
>>>>
>>>> On a fresh install of cygwin with gcc-g++, this program will throw an
>>>> exception from the std::string constructor:
>>>>
>>>> c++ -x c++ - <<END
>>>> #include <string>
>>>> int main() { std::string str(nullptr); return 0; }
>>>> END
>>>>
>>>> When it's executed from the shell it returns zero, but execution stops
>>>> at the exception.
>>>>
>>>> $ ./a; echo $?
>>>> 0
>>>>
>>>> When executed under gdb, the exception is caught, and the process exits
>>>> non-zero when continued:
>>>>
>>>> (gdb) r
>>>> Starting program: /home/corngood/a
>>>> [New Thread 4300.0x1390]
>>>> [New Thread 4300.0x1d24]
>>>> [New Thread 4300.0x1d48]
>>>> [New Thread 4300.0x80c]
>>>> gdb: unknown target exception 0x20474343 at 0x7ff8d2cfa799
>>>> Thread 1 "a" received signal ?, Unknown signal.
>>>> 0x00007ff8d2cfa799 in RaiseException () from /cygdrive/c/WINDOWS/System32/KERNELBASE.dll
>>>> (gdb) c
>>>> Continuing.
>>>> [Thread 4300.0x1d24 exited with code 541541187]
>>>> [Thread 4300.0x1870 exited with code 541541187]
>>>> [Thread 4300.0x1d48 exited with code 541541187]
>>>> [Thread 4300.0x1390 exited with code 541541187]
>>>> [Inferior 1 (process 4300) exited with code 04021641503]
>>>> (gdb)
>>>>
>>>> When executed under strace, it exits with an error as expected:
>>>>
>>>> $ strace -o /dev/null a; echo $?
>>>> 67
>>>>
>>>> That's as far as I've investigated so far.
>>>
>>> Is this the same issue with
>>> https://cygwin.com/pipermail/cygwin/2019-October/242795.html ?
>>>
>>> As far as I tested, this does not occur in 32-bit cygwin.
>>
>> This doesn't seem to be a new issue.  I found the following report from 6 years
>> ago, on Cygwin 1.7.30 with GCC 4.9.0:
>>
>> https://stackoverflow.com/questions/24402412/program-executed-on-cygwin-does-not-report-a-thrown-exception
> 
> Thanks for the information. But I still wonder why 32-bit and 64-bit
> cygwin behave differently.

I'm no C++ expert, but my understanding after a brief internet search is that an 
uncaught exception is supposed to cause std::terminate to be called.  So I 
installed gcc-debuginfo and ran the OP's test case under gdb with a breakpoint 
at 'terminate'.  On 32-bit Cygwin I got the expected behavior:

Thread 1 "exception_test" hit Breakpoint 1, std::terminate ()
     at /usr/src/debug/gcc-9.3.0-2/libstdc++-v3/libsupc++/eh_terminate.cc:96
96        __atomic_load (&__terminate_handler, &func, __ATOMIC_ACQUIRE);
(gdb) bt
#0  std::terminate ()
     at /usr/src/debug/gcc-9.3.0-2/libstdc++-v3/libsupc++/eh_terminate.cc:96
#1  0x57c45909 in __cxxabiv1::__cxa_throw (obj=obj AT entry=0x800396e8,
     tinfo=tinfo AT entry=0x57c646a8 <typeinfo for std::logic_error>,
     dest=0x57be6c60 <std::logic_error::~logic_error()>)
     at /usr/src/debug/gcc-9.3.0-2/libstdc++-v3/libsupc++/eh_throw.cc:95
#2  0x57c49223 in std::__throw_logic_error (
     __s=__s AT entry=0x57c60160 <cplus_demangle_builtin_types+10272> "basic_string::
_S_construct null not valid")
     at /usr/src/debug/gcc-9.3.0-2/libstdc++-v3/src/c++11/functexcept.cc:66
[...]

On 64-bit Cygwin, however, I got the behavior reported by the OP:

gdb: unknown target exception 0x20474343 at 0x7ff8cccca719

Thread 1 "exception_test" received signal ?, Unknown signal.
0x00007ff8cccca719 in RaiseException () from /c/WINDOWS/System32/KERNELBASE.dll
(gdb) c
Continuing.
[Thread 4508.0x3e20 exited with code 541541187]
[Thread 4508.0x5bc exited with code 541541187]
[Thread 4508.0x5ee8 exited with code 541541187]
[Thread 4508.0x1cd0 exited with code 541541187]
[Inferior 1 (process 4508) exited with code 04021641503]

Note that the breakpoint at 'terminate' is not reached.  I tried putting a 
breakpoint at __cxa_throw and stepping through from there, but I don't really 
understand what's going on.  Someone who knows the innards of exception handling 
will have to look at this.

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019