Hello Stas,Hi. :)
OK, so the original problem was that to get theBecause I don't think we broke the existing code, or did we?Probably not, but it seems to me that there is some small
possibility that library code that makes use of sigaltstack()
to test whether a signal is being handled on an alternate signal
stack, unaware that the main program employed SS_AUTODISARM,
could be confused/broken. I've no idea how likely this scenario
is though. (I imagine it's rather unlikely.)
But my understanding differs.and posix seems to allow anyYes, long ago someone got confused, as I've noted in a recently added
other value for enable, which can be (on linux) SS_ONSTACK,
not only 0.
BUGS section in the page:
At this point the alt stack is set back to SS1,And SS_AUTODISARM can be ORed with the value.So, I've done only limited experimentation here, but this is what
âââââââââââââââââââââââââââââââââââââââââââââââââââââââMy memory may be wrong here, but I think setting
âFIXME â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââ
âWas it intended that one can set up a different â
âalternative signal stack in this scenario? (In passâ â
âing, if one does this, the sigaltstack(NULL, â
â&old_ss) now returns old_ss.ss_flags==SS_AUTODISARM â
ârather than old_ss.ss_flags==SS_DISABLE. The API â
âdesign here seems confusing... â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââ
up another alt stack was not supposed because the
previous settings would be restored upon sighandler
return. AFAIK I was trying to make up a proposal to
get such attempts explicitly blocked rather than
silently ignored, but again the simplicity was chosen.
I see in one experiment:
[[
* Set up two handlers for SIGX and SIGY, both using SA_ONSTACK.
* Establish alternate SS (1) using SS_AUTODISARM
[SIGA is delivered]
* Handler for SIGA is called and handler is executed on alternate SS 1.
* The handler establishes a new alternate SS (2) with SS_AUTODISARM.
[SIGB is delivered]
* Handler for SIGB is called and handler is executed on alternate SS 2.
* Handler for SIGB returns
[SIGB is delivered]
* Handler for SIGB is called and handler is executed on alternate SS 2.
* Handler for SIGB returns
* Handler of SIGA returns
[SIGA is delivered]Only if you deliver SIGB while still inside SIGA handler,
* Handler for SIGA is called and handler is executed on alternate SS 1.
]]
Summary: setting up another alternate signal stack seems to "work".
API history is littered with stories where users found out thatIt will disappear at the exit from SIGA.
something unforeseen "worked", and so they used it. The question
is: what can go wrong if people do try using this "feature"?
The kernel already has the sigaltstack test-case,Thanks for the confirmation.SS_AUTODISARMInitially this flag was supposed to be ORed with
The alternate signal stack has been marked to be
autodisarmed as described above.
the old values. Your descrition is correct, but if
more bit flags are added, this may became a
problem, as you are always treating it as a separate
value, not a bit flag.
At the end of this mail is a test program that I used to experiment
with this stuff. Here's a sample run that demonstrates the scenario
described above: