[newlib-cygwin] Cygwin: signal: Revert _cygtls::inside_kernel() change

Takashi Yano via Cygwin-cvs <[email protected]>
Newsgroups gmane.os.cygwin.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=9c3e1e9ea9d2d930fef1ae6a62e61b101c1e047c

commit 9c3e1e9ea9d2d930fef1ae6a62e61b101c1e047c
Author: Takashi Yano <[email protected]>
Date:   Wed May 28 15:31:23 2025 +0900

    Cygwin: signal: Revert _cygtls::inside_kernel() change
    
    This patch partially reverts the commit b7097ab39ed0 because it
    seems to cause issues when longjmp is used within a signal handler.
    The problem that the commit addressed no longer occurs even if this
    change is reverted.
    
    Fixes: b7097ab39ed0 ("Cygwin: signal: Revive toggling incyg flag in call_signal_handler()")
    Reviewed-by: Corinna Vinschen <[email protected]>
    Signed-off-by: Takashi Yano <[email protected]>

Diff:
---
 winsup/cygwin/exceptions.cc           | 6 +++---
 winsup/cygwin/local_includes/cygtls.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index 804adc92b..bcc7fe6f8 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -932,7 +932,7 @@ _cygtls::interrupt_now (CONTEXT *cx, siginfo_t& si, void *handler,
   /* Delay the interrupt if we are
      1) somehow inside the DLL
      2) in a Windows DLL.  */
-  if (incyg || inside_kernel (cx, true))
+  if (incyg || inside_kernel (cx))
     interrupted = false;
   else
     {
@@ -1797,7 +1797,7 @@ _cygtls::call_signal_handler ()
 
       int this_errno = saved_errno;
       reset_signal_arrived ();
-      incyg = false;
+      incyg = 0;
       current_sig = 0;	/* Flag that we can accept another signal */
 
       /* We have to fetch the original return address from the signal stack
@@ -1910,7 +1910,7 @@ _cygtls::call_signal_handler ()
 	}
       unlock ();
 
-      incyg = true;
+      incyg = 1;
 
       set_signal_mask (_my_tls.sigmask, (this_sa_flags & SA_SIGINFO)
 					? context1.uc_sigmask : this_oldmask);
diff --git a/winsup/cygwin/local_includes/cygtls.h b/winsup/cygwin/local_includes/cygtls.h
index 1b3bf65f1..615361d3f 100644
--- a/winsup/cygwin/local_includes/cygtls.h
+++ b/winsup/cygwin/local_includes/cygtls.h
@@ -198,7 +198,7 @@ public: /* Do NOT remove this public: line, it's a marker for gentls_offsets. */
   class san *andreas;
   waitq wq;
   volatile int current_sig;
-  unsigned incyg;
+  volatile unsigned incyg;
   volatile unsigned stacklock;
   __tlsstack_t *stackptr;
   __tlsstack_t stack[TLS_STACK_SIZE];
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.