delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1999/08/30/11:46:44

Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-developers-unsubscribe-archive-cygwin-developers=delorie DOT com AT sourceware DOT cygnus DOT com>
List-Subscribe: <mailto:cygwin-developers-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin-developers/>
List-Post: <mailto:cygwin-developers AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-developers-help AT sourceware DOT cygnus DOT com>,
<http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com
From: Chris Faylor <cgf AT cygnus DOT com>
Date: Mon, 30 Aug 1999 11:38:50 -0400
To: Vadim Egorov <egorovv AT 1c DOT ru>
Cc: "cygwin-developers AT sourceware DOT cygnus DOT com" <cygwin-developers AT sourceware DOT cygnus DOT com>
Subject: Re: longjmp problem
Message-ID: <19990830113850.A2290@cygnus.com>
Reply-To: cygwin-developers AT sourceware DOT cygnus DOT com
Mail-Followup-To: Vadim Egorov <egorovv AT 1c DOT ru>,
"cygwin-developers AT sourceware DOT cygnus DOT com" <cygwin-developers AT sourceware DOT cygnus DOT com>
References: <37C65CF3 DOT 50E89A09 AT 1c DOT ru>
Mime-Version: 1.0
X-Mailer: Mutt 0.95.6i
In-Reply-To: <37C65CF3.50E89A09@1c.ru>; from Vadim Egorov on Fri, Aug 27, 1999 at 01:40:03PM +0400

On Fri, Aug 27, 1999 at 01:40:03PM +0400, Vadim Egorov wrote:
>Hello,
>
>There is a problem with setjmp/longjmp/signals/exceptions that can be
>demonstrated by the following code:
>
>static jmp_buf	env;
>static sigset_t set = {0};
>
>static void sig_handler(int sig)
>{
>    sigprocmask(SIG_UNBLOCK, &set, 0);
>    longjmp(env, sig);
>}
>
>int main(int argc, char * * argv)
>{
>    sigaddset(&set, SIGSEGV);
>
>    for ( int i = 0 ; i < 2; i++)
>    {
>        if ( setjmp(env) == 0 ) 
>        {
>            signal(SIGSEGV, ssig_handler);
>            printf("exception ...");
>            *(int*)0 = 1;
>        }
>        else
>        {
>            printf("trapped\n");
>        }
>    }
>    return 0;
>
>}
>
>It traps exception only once and than hangs.  The problem seems to be
>in longjmp code.  If I load CRTDLL.DLL dynamically and use
>setjmp/longjmp from there all works.  I traced MS longjmp and noticed
>that it calls RtlUnwind which seems do the trick.  In addition this
>code works on Linux without signal unblocking - it is necessary only if
>SIGSEGV is signaled by raise.

It should be pretty easy to run this in a debugger and see where it's
hanging or attach to a hung process and get a stack trace from a couple
of the threads.

I would like to encourage people to do this.  It could help DJ or me
figure out where the problem lies without having to duplicate somebody
else's effort.

In this case, I suspect that setjmp itself is being interrupted so env
is in an unknown state when the the signal handler uses it.

-chris

- Raw text -


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