delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/07/08/10:10:06

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=1.6 required=5.0 tests=AWL,BAYES_40,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE
X-Spam-Check-By: sourceware.org
Message-ID: <2881D39E5C7C40EFB6B9D0E9BF487FCA@amber>
From: "Don Ward" <don2387ward AT sprynet DOT com>
To: <cygwin AT cygwin DOT com>
References: <346D8CF793D04BC99A972949F9555CC3 AT amber> <7e6495952c8c6ba0be89f784d7fcfe1e AT shell DOT sh DOT cvut DOT cz>
Subject: Re: gcc4: throwing exception from signal handler
Date: Thu, 8 Jul 2010 10:08:30 -0400
MIME-Version: 1.0
X-ELNK-Trace: 289b4676444fa27bf7f185e0b4d0be75e5331016acda17f924d65293e0d071dec48ce739d7a02cb7350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c
X-IsSubscribed: yes
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

Václav Haismam wrote:

> On Thu, 8 Jul 2010 09:01:41 -0400, "Don Ward" wrote:
>> I would like to be able to catch certain signals (SIGSEGV and SIGSYS)
> and
>> throw a C++ exception (to be caught in a try/catch construct).  As a
>> simple
>> example:
>>[...]
>> Am I misunderstanding how this should work or doing something wrong?  Or
>> is
>> this a problem with Cygwin or gcc?
> I do not think that handling SIGSEGV with an exception is a good idea.

I agree, in general.

> Unless you get SIGSEGV as a result of some well thought through memory
> management games

But that is what I am doing.  I also want to catch SIGSYS to determine 
whether shmat() is available when we don't know in advance whether cygserver 
is running.  In either case, if the signal is generated I want to catch it 
and try something else.  In these contexts I want to treat  SIGSEGV and 
SIGSYS as non-fatal error returns.

. . .
> I am not sure but I do not think that throwing exceptions from signal
> handlers is generally supported.

It appears that is what the -fnon-call-exceptions is for.  From the 
gcc-4.3.5 manual:

"-fnon-call-exceptions:  Generate code that allows trapping instructions to 
throw exceptions. Note that this requires platform-specific runtime support 
that does not exist everywhere."

I guess one question is whether the runtime support exists in Cygwin 1.7 
with gcc 4.3.4.

-- Don W.


--
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