Handle exceptions in sigaltstack

* signal.cc (sigaltstack): Add fault handler.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2015-06-20 18:48:09 +02:00
parent 22465796ed
commit 74d272cc02
1 changed files with 35 additions and 21 deletions

View File

@ -630,10 +630,13 @@ sigaltstack (const stack_t *ss, stack_t *oss)
{ {
_cygtls& me = _my_tls; _cygtls& me = _my_tls;
__try
{
if (ss) if (ss)
{ {
if (me.altstack.ss_flags == SS_ONSTACK) if (me.altstack.ss_flags == SS_ONSTACK)
{ {
/* An attempt was made to modify an active stack. */
set_errno (EPERM); set_errno (EPERM);
return -1; return -1;
} }
@ -647,11 +650,16 @@ sigaltstack (const stack_t *ss, stack_t *oss)
{ {
if (ss->ss_flags) if (ss->ss_flags)
{ {
/* The ss argument is not a null pointer, and the ss_flags
member pointed to by ss contains flags other than
SS_DISABLE. */
set_errno (EINVAL); set_errno (EINVAL);
return -1; return -1;
} }
if (ss->ss_size < MINSIGSTKSZ) if (ss->ss_size < MINSIGSTKSZ)
{ {
/* The size of the alternate stack area is less than
MINSIGSTKSZ. */
set_errno (ENOMEM); set_errno (ENOMEM);
return -1; return -1;
} }
@ -660,5 +668,11 @@ sigaltstack (const stack_t *ss, stack_t *oss)
} }
if (oss) if (oss)
memcpy (oss, &me.altstack, sizeof *oss); memcpy (oss, &me.altstack, sizeof *oss);
}
__except (EFAULT)
{
return EFAULT;
}
__endtry
return 0; return 0;
} }