Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com Message-ID: <37C65CF3.50E89A09@1c.ru> Date: Fri, 27 Aug 1999 13:40:03 +0400 From: Vadim Egorov X-Mailer: Mozilla 4.61 [en] (WinNT; I) X-Accept-Language: ru,en MIME-Version: 1.0 To: "cygwin-developers AT sourceware DOT cygnus DOT com" Subject: longjmp problem Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 8bit X-MDaemon-Deliver-To: cygwin-developers AT sourceware DOT cygnus DOT com X-Return-Path: EgorovV AT 1c DOT ru 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. Does anyone have any opinion about this matter? Regards Vadim -- ********************************************* Vadim Egorov, 1C * Вадим Егоров,1C egorovv AT 1c DOT ru * egorovv AT 1c DOT ru *********************************************