delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2019/12/18/10:11:32

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:from:to:in-reply-to:subject:date:message-id
:mime-version:content-transfer-encoding:content-type:references;
q=dns; s=default; b=CTqbJcOfATgtKMNC+rPg1oAZnkVjx09LUwkW/s4qxun
o0VA4MlCxG6bTNdBO7cvqfCV542SA0TYDD52fbAwu0KzTzGr+O9zo5rHko+n0zRh
xWkhOARzCcv3ZUslG7t834N/iqNtVeVG614gM9YrarWftDI3OIe7lOgtIhwQKTVE
=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:from:to:in-reply-to:subject:date:message-id
:mime-version:content-transfer-encoding:content-type:references;
s=default; bh=HvzTarmF+lAqioXSvlWbFkEhln4=; b=WGbAv153CgZvUKTin
P25onAoofkulmVfw7rhHgO5fVY7NVdnO3DEG/zLr7CYUiGORrYqA5l41yjbHv9fD
042HZFbA4uILNZ6sP32WcZjPte7uJbsWQK49ykD6tueJk5XpTVEQ5wheYwwEuJ3k
KQ/jD6cRmVwU9kq/xVsM+xhKSw=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL,BAYES_00,CYGWIN_OWNER_BODY,GIT_PATCH_2,KAM_NUMSUBJECT,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy=H*UA:15.0, H*x:15.0, H*r:sk:2019121, Projects
X-HELO: mailout1.w1.samsung.com
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20191218151028euoutp010dcc1cab55afc5551840ed17a0c10dd5~hf8Tijpxx1805718057euoutp01B
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1576681828; bh=RFNw1NckXg2Bltc7o1yf3ffadbmgzhriMlhxsGzCLqQ=; h=From:To:In-Reply-To:Subject:Date:References:From; b=Yrdk/1z2yFAS66FGI7A8kbK9JwWIUin+10hNCzz+akBL1aV6uTdQiCluCowg/g/nG gVlt0vsCoJpHo1QOiJT5e0FWmlk0r1PcOtjaFJ6gKBLWid/2nqHeQootYQ3I9ZI4hU KUHukA7416Dh5eZj3uv+SG6a4u2xr2dNh7/31afo=
From: "Pavel Fedin" <p DOT fedin AT samsung DOT com>
To: <Brian DOT Inglis AT SystematicSw DOT ab DOT ca>, <cygwin AT cygwin DOT com>
In-Reply-To: <b46cefcb-144b-50f8-1f79-d2879b4e4c25@SystematicSw.ab.ca>
Subject: RE: [BUG] try..catch does not work if compiled with clang 8.0
Date: Wed, 18 Dec 2019 18:10:26 +0300
Message-ID: <016d01d5b5b5$47d6b8a0$d78429e0$@samsung.com>
MIME-Version: 1.0
X-CMS-MailID: 20191218151027eucas1p159ba2a08f62e0b2cf5f58fdaa9e03106
X-Msg-Generator: CA
X-RootMTR: 20191217093504eucas1p14cced4e1f9fcec50e44e9223d1761858
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20191217093504eucas1p14cced4e1f9fcec50e44e9223d1761858
References: <CGME20191217093504eucas1p14cced4e1f9fcec50e44e9223d1761858 AT eucas1p1 DOT samsung DOT com> <000701d5b4bd$42c086f0$c84194d0$@samsung.com> <af3cb99f-f1cc-3bcc-9644-310c259eb222 AT SystematicSw DOT ab DOT ca> <a9a62b50-688c-5747-266a-e7bb8157adbb AT gmail DOT com> <b46cefcb-144b-50f8-1f79-d2879b4e4c25 AT SystematicSw DOT ab DOT ca>
X-IsSubscribed: yes
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id xBIFB8Tt002156

 Well, it turned out more complicated than i thought. Here is the reduced reproducer:
--- cut catch_test.cpp ---
#include <stdexcept>
#include <iostream>
#include <vector>
#include <string>
#include <fstream>

void from_file(const std::string &filepath, std::vector<int8_t> &data);

int main()
{
    try
    {
      std::vector<int8_t> data;

      from_file("no_such_file.bin", data);
      std::cout << "Success ???" << std::endl;
    }
    catch (const std::exception &e)
    {
      std::cout << "std::exception: " << e.what() << std::endl;
    }

    return 0;
}
--- cut catch_test.cpp ---
--- cut catch_test_2.cpp ---
#include <stdexcept>
#include <iostream>
#include <vector>
#include <string>
#include <fstream>

using namespace std;

template <typename T> void from_file_impl(const string &filepath, vector<T> &data)
{
//  data.clear();

  std::ifstream ifs(filepath.c_str());
  if (ifs.rdstate() & ifstream::failbit)
  {
    throw std::runtime_error("Error in reading " + filepath);
  }

/*  T buffer;

  while (ifs.read(reinterpret_cast<char *>(&buffer), sizeof(T)))
  {
    data.push_back(buffer);
  }*/
}

void from_file(const string &filepath, vector<int8_t> &data) { from_file_impl(filepath, data); }
--- cut catch_test_2.cpp ---
--- cut console log ---
CORP+p DOT fedin AT P-FEDIN01 /cygdrive/d/Projects/Test
$ clang++-8 catch_test.cpp catch_test_2.cpp -g -o catch_test

CORP+p DOT fedin AT P-FEDIN01 /cygdrive/d/Projects/Test
$ ./catch_test

CORP+p DOT fedin AT P-FEDIN01 /cygdrive/d/Projects/Test
$ g++.exe catch_test.cpp catch_test_2.cpp -g -o catch_test

CORP+p DOT fedin AT P-FEDIN01 /cygdrive/d/Projects/Test
$ ./catch_test

CORP+p DOT fedin AT P-FEDIN01 /cygdrive/d/Projects/Test
$ clang++-5.0 catch_test.cpp catch_test_2.cpp -g -o catch_test

CORP+p DOT fedin AT P-FEDIN01 /cygdrive/d/Projects/Test
$ ./catch_test
std::exception: Error in reading no_such_file.bin

CORP+p DOT fedin AT P-FEDIN01 /cygdrive/d/Projects/Test
$
--- cut console log ---

 So, the problem actually reproduces with both clang 8 and gcc (7.4.0 on my system). clang 5 works fine.

 You could also be interested in strace (here is end of the output only, the beginning is quite long and not very interesting):
--- cut ---
22301  238862 [main] catch_test 6078 seterrno_from_nt_status: /home/corinna/src/cygwin/cygwin-3.1.0/cygwin-3.1.0-1.x86_64/src/newlib-cygwin/winsup/cygwin/fhandler.cc:724 status 0xC0000034 -> windows error 2
   75  238937 [main] catch_test 6078 geterrno_from_win_error: windows error 2 == errno 2
   42  238979 [main] catch_test 6078 fhandler_base::open: 0xC0000034 = NtCreateFile (0x10, 0x80100000, \??\D:\Projects\Test\no_such_file.bin, io, NULL, 0x0, 0x7, 0x1, 0x4020, NULL, 0)
   78  239057 [main] catch_test 6078 fhandler_base::open: 0 = fhandler_base::open(\??\D:\Projects\Test\no_such_file.bin, 0x108000)
   41  239098 [main] catch_test 6078 fhandler_base::open_fs: 0 = fhandler_disk_file::open(\??\D:\Projects\Test\no_such_file.bin, 0x8000)
   99  239197 [main] catch_test 6078 open: -1 = open(no_such_file.bin, 0x8000), errno 2
--- Process 2620 (pid: 6078), exception 20474343 at 00007ff8c73fa388
--- Process 2620 (pid: 6078) thread 12836 exited with status 0x20474343
--- Process 2620 (pid: 6078) thread 3972 exited with status 0x20474343
--- Process 2620 (pid: 6078) thread 15568 exited with status 0x20474343
--- Process 2620 (pid: 6078) thread 5428 exited with status 0x20474343
--- Process 2620 (pid: 6078) thread 2364 exited with status 0x20474343
--- Process 2620 (pid: 6078) thread 16008 exited with status 0x20474343
--- Process 2620 exited with status 0x20474343
--- cut ---
 So, a Windows exception is reported, then the whole thing silently quits.
 I have an impression that it has to do with the bug i previously reported (and someone here claimed he could reproduce it)

Kind regards,
Pavel Fedin
Senior Engineer
Samsung Electronics Research center Russia


> -----Original Message-----
> From: cygwin-owner AT cygwin DOT com [mailto:cygwin-owner AT cygwin DOT com] On Behalf Of Brian Inglis
> Sent: Wednesday, December 18, 2019 3:05 AM
> To: cygwin AT cygwin DOT com
> Subject: Re: [BUG] try..catch does not work if compiled with clang 8.0
> 
> On 2019-12-17 13:51, Csaba Ráduly wrote:
> > On 17/12/2019 17:29, Brian Inglis wrote:
> >> On 2019-12-17 02:35, Pavel Fedin wrote:
> >>> I haven't upgraded for a while and today i finally decided to do so. After
> >>> rebuilding by project with clang++ 8.0 i found out that try...catch construct
> >>> doesn't work. The program just gets silently aborted.
> >>> Switched back to old clang++ 5.0 and it works.
> >>> Also an old bug which i reported some (a while) time ago persists: uncaught
> >>> throw does not print anything.
> >>> OS is Windows 10 x86/64.
> >> It is unlikely that try/catch does not work in the general case for clang++8,
> >> and your post has insufficient information to reproduce the problem.
> >
> > a.k.a. https://www.chiark.greenend.org.uk/~sgtatham/bugs.html#respect
> 
> Indeed!
> 
> > WJFFM
> >> $ cat catcher.cpp
> > #include <stdexcept>
> > #include <iostream>
> >
> > int pitcher()
> > {
> >     throw std::runtime_error{"Ouch"};
> > }
> >
> > int main()
> > {
> >     try {
> >         return pitcher();
> >     }
> >     catch (std::exception const&e) {
> >         std::cout << "Caught a " << typeid(e).name() << " - " << e.what() << '\n';
> >         return 42;
> >     }
> > }
> >
> > $ g++ -v -Wall -Wpedantic -Wextra -g  catcher.cpp
> 
> > $ ./a.exe
> > Caught a St13runtime_error - Ouch
> 
> The report was about clang++ 8 vs 5; tweaked source to build under 5 and 8:
> ...
> #include <typeinfo>
> 
> int pitcher()
> {
>     throw std::runtime_error("Ouch");
> }
> ...
> 
> but same WJFFM results:
> 
> $ clang++-5.0 -g -Og -Wpedantic -Wall -Wextra -o try-catch-stc{,.cpp}
> $ ./try-catch-stc
> Caught a St13runtime_error - Ouch
> 
> $ clang++-8 -g -Og -Wpedantic -Wall -Wextra -o try-catch-stc{,.cpp}
> $ ./try-catch-stc
> Caught a St13runtime_error - Ouch
> 
> --
> Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
> 
> This email may be disturbing to some readers as it contains
> too much technical detail. Reader discretion is advised.
> 
> --
> Problem reports:       https://protect2.fireeye.com/url?k=b437d571-e9e489fe-b4365e3e-
> 0cc47a31ce52-fd9c07d8a89a97f5&u=http://cygwin.com/problems.html
> FAQ:                   https://protect2.fireeye.com/url?k=2e1da12d-73cefda2-2e1c2a62-
> 0cc47a31ce52-67f7089b29388f59&u=http://cygwin.com/faq/
> Documentation:         https://protect2.fireeye.com/url?k=3f2aeb24-62f9b7ab-3f2b606b-
> 0cc47a31ce52-9528889b998d683e&u=http://cygwin.com/docs.html
> Unsubscribe info:      https://protect2.fireeye.com/url?k=b1682add-ecbb7652-b169a192-
> 0cc47a31ce52-e02defedfa7edb6b&u=http://cygwin.com/ml/#unsubscribe-simple




--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


- Raw text -


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