problem mixing C++ exceptions and setjmp/longjmp

John W. Eaton jwe@bevo.che.wisc.edu
Fri Mar 11 22:04:00 GMT 2005


I believe the following program should print

  main: calling doit
  doit: calling toit
  toit: throwing exception
  toit: caught exception, longjumping
  doit: longjump landed, throwing exception
  main: caught exception

but on the current Cygwin (updated today) using the 1.5.13-1
cygwin.dll and either gcc 3.3 or 3.4, it crashes with a segfault just
after printing the next to last line:

  doit: longjump landed, throwing exception

I tried going back to 1.5.12, but that did not fix the problem.

Can anyone reproduce this problem?

This problem affects GNU Octave, as it uses this technique to handle
interrupts in code that is a mixture of C++, C, and Fortran.  If
SIGINT arrives in a section of Octave code, the signal handler sets a
flag and then returns, letting Octave check the flag periodically.  At
some safe location, an exception is thrown that will return control
to the top level of the main interpreter loop.  If SIGINT arrives
inside some foreign code (say, readline, or some Fortran code) then
the signal handler jumps back to the location of the call to the
foreign code.  At that point, an exception is thrown to get back to
the top level.  I've not had problems with this approach until
recently when I upgraded my Cygwin installation.  Now Ctrl-C at the
prompt causes a segfault.  The program below is a distillation of the
key features of the Octave code, and shows the same problem.

Any clues?

Thanks,

jwe

-- 
www.octave.org | jwe@octave.org

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: except.cc
URL: <http://cygwin.com/pipermail/cygwin/attachments/20050311/5125ed2a/attachment.cc>
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list