This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem with exception handling on alt stacks


On May 31 15:21, Erik Bray wrote:
> Hi all,
> 
> I recently ran into a tricky problem when working with cysignals [1]
> on Cygwin:  Cysignals provides signal handlers for code written in C
> or Cython running in a Python interpreter, which converts otherwise
> unhandled signals into Python exceptions.
> 
> It recently started using sigaltstack [2] to provide an alternate
> stack to run signal handlers on, specifically for SIGSEGV (in case the
> cause thereof was a stack overflow).
> 
> Cygwin supports this in principle, but things get pretty flaky at that
> point, because if any exception occurs while running on an altstack,
> Cygwin will handle it if the exception came from Cygwin itself, but
> not otherwise, per this note [3]
> 
> > TODO: What we do here is to handle only __try/__except blocks in Cygwin.
> > "Normal" exceptions will simply exit the process. Still, better
> > than nothing... */
> 
> Is that really better than nothing though?  The result is that the
> process dies with a (Cygwin) exit code of 0.  This is quite
> surprising!  Even if there were really nothing else to be done I
> wonder if Cygwin could try as hard as possible to at least set a
> non-zero exit code in this case.
> 
> Now, it's true what comment above that says:
> 
> > normal SEH handlers are skipped, because the OS exception
> > handling considers the current (alternate) stack "broken"
> 
> However, I was able to work around this in cysignals [4] by adding a
> VectoredContinueHandler which, in this case, is at least able to
> convert the exception code to the appropriate POSIX return code and
> exit the process.  And superficially it seems to work quite reliably.
> But I wonder if there isn't something "wrong" about this from the
> Cygwin perspective, and if it shouldn't at least try to do the same...

Good point.  I'm not sure I have time to look into this for the time
being, but I'm not at all opposed to patches in this area.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: signature.asc
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]