aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--winsup/cygwin/exceptions.cc8
-rw-r--r--winsup/cygwin/release/3.6.15
2 files changed, 13 insertions, 0 deletions
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index 2e25aa2..a3aae2c 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -1791,6 +1791,13 @@ _cygtls::call_signal_handler ()
to 16 byte. */
uintptr_t new_sp = ((uintptr_t) _my_tls.altstack.ss_sp
+ _my_tls.altstack.ss_size) & ~0xf;
+ /* Copy context1 to the alternate signal stack area, because the
+ context1 allocated in the normal stack area is not accessible
+ from the signal handler that uses alternate signal stack. */
+ thiscontext = (ucontext_t *) ((new_sp - sizeof (ucontext_t)) & ~0xf);
+ memcpy (thiscontext, &context1, sizeof (ucontext_t));
+ new_sp = (uintptr_t) thiscontext;
+
/* In assembler: Save regs on new stack, move to alternate stack,
call thisfunc, revert stack regs. */
#ifdef __x86_64__
@@ -1834,6 +1841,7 @@ _cygtls::call_signal_handler ()
#else
#error unimplemented for this target
#endif
+ memcpy (&context1, thiscontext, sizeof (ucontext_t));
}
else
/* No alternate signal stack requested or available, just call
diff --git a/winsup/cygwin/release/3.6.1 b/winsup/cygwin/release/3.6.1
index 40ef297..95c2c05 100644
--- a/winsup/cygwin/release/3.6.1
+++ b/winsup/cygwin/release/3.6.1
@@ -10,3 +10,8 @@ Fixes:
- getlocalename_l: Fix a crash and handle LC_ALL according to final
POSIX-1.2024 docs.
Addresses: https://cygwin.com/pipermail/cygwin/2025-March/257715.html
+
+- Copy context to alternate signal stack area in call_signal_handler()
+ in the SA_ONSTACK case, because locally-copied context on the normal
+ stack area is not accessible from the signal handler.
+ Addresses: https://cygwin.com/pipermail/cygwin/2025-March/257714.html