Re: cyggfortran-3.dll broken ?
marco atzeri wrote: Sent: Wednesday, March 23, 2011 12:36 PM Subject: Re: cyggfortran-3.dll broken ? [snip...] So I caused myself the problem as I added all those functions to cygwin But they were just in time to save me having to abandon my primary application on Cygwin. Thank you. Your efforts are appreciated. Best regards, -- Don W. [snip...] Regards Marco -- 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
gcc4: throwing exception from signal handler
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: #include stdio.h #include string.h #include stdexcept #include signal.h void throw_signal( int signum ) { // fprintf(stderr,throw_signal: before throw; signum=%d\n,signum);fflush(stderr); throw std::runtime_error (throw_signal); } int main() { struct sigaction new_action, d_old_action; memset (new_action, 0, sizeof (new_action)); new_action.sa_handler = throw_signal; sigemptyset (new_action.sa_mask); new_action.sa_flags = 0; if (sigaction (SIGSEGV, new_action, d_old_action) 0){ perror (sigaction (install new)); throw std::runtime_error (sigaction); } try { int j = *((int *)NULL); } catch (...){ printf(caught exception\n); } } g++ 3.3.4 gives the result I expect: $ sh /usr/bin/set-gcc-default-3.sh $ gcc --version gcc (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) Copyright (C) 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ g++ -fnon-call-exceptions throw_segv.cc $ ./a.exe caught exception but g++ 4.3.4 aborts after the exception is thrown and before it is caught: $ sh /usr/bin/set-gcc-default-4.sh $ gcc --version gcc (GCC) 4.3.4 20090804 (release) 1 Copyright (C) 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ g++ -fnon-call-exceptions throw_segv.cc $ ./a.exe terminate called after throwing an instance of 'std::runtime_error' what(): throw_signal Aborted (core dumped) Am I misunderstanding how this should work or doing something wrong? Or is this a problem with Cygwin or gcc? Thanks, -- Don W. cygcheck.out Description: Binary data throw_segv.cc Description: Binary data -- 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
Re: gcc4: throwing exception from signal handler
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
Re: gcc4: throwing exception from signal handler
Dave Korn wrote: On 08/07/2010 14:01, 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? Throwing exceptions from a signal handler is a can of worms that requires support from both the compiler and the C runtime. Understood! I was working on adding this support for the distro package of gcc-4.5 before I had to go AWOL a couple of weeks ago; it requires building the Cygwin DLL with EH tables, and adding support in the last-chance stack unwinder in libgcc that is able to unwind past our sigfe/sigbe stuff. I'm glad someone is (or will be) working on it. In the meanwhile, I can make do with gcc 3.4.4. Thanks, -- 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