https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=a89b9cb050693078a81e2376c107e7d7df98ef06

commit a89b9cb050693078a81e2376c107e7d7df98ef06
Author: Jon Turney <jon.tur...@dronecode.org.uk>
Date:   Sat May 17 14:30:35 2025 +0100

    Cygwin: Only return true from try_to_debug() if we launched a JIT debugger
    
    This fixes constantly replaying the exception if we have a segfault
    while a debugger is already attached, e.g. stracing a segv, see:
    
    https://cygwin.com/pipermail/cygwin/2025-May/258144.html
    
    Future work:
    
    The 'debugging' static in exception::handle(), which makes us replay the
    exception the next half a million times it's hit seems like cruft, maybe
    we should look at if it's possible to remove that?
    
    Fixes: 91457377d6c9 ("Cygwin: Make 'ulimit -c' control writing a coredump")
    Reported-by: Christian Franke <christian.fra...@t-online.de>
    Signed-off-by: Jon Turney <jon.tur...@dronecode.org.uk>
    (cherry picked from commit b39b510c1ce68757e79410585262ca2cd48da839)

Diff:
---
 winsup/cygwin/exceptions.cc | 4 +++-
 winsup/cygwin/release/3.6.2 | 3 +++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index 9763a1b04..876b79e36 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -597,7 +597,7 @@ try_to_debug ()
     {
       extern void break_here ();
       break_here ();
-      return 1;
+      return 0;
     }
 
   /* Otherwise, invoke the JIT debugger, if set */
@@ -812,6 +812,8 @@ exception::handle (EXCEPTION_RECORD *e, exception_list 
*frame, CONTEXT *in,
   else if (try_to_debug ())
     {
       debugging = 1;
+      /* If a JIT debugger just attached, replay the exception for the benefit
+        of that */
       return ExceptionContinueExecution;
     }
 
diff --git a/winsup/cygwin/release/3.6.2 b/winsup/cygwin/release/3.6.2
index 915bd0150..3b1944d99 100644
--- a/winsup/cygwin/release/3.6.2
+++ b/winsup/cygwin/release/3.6.2
@@ -25,3 +25,6 @@ Fixes:
 
 - Fix deadlock for opening both side of a fifo in a process.
   Addresses: https://cygwin.com/pipermail/cygwin/2025-May/258138.html
+
+- Fix infinite exception loop on segmentation fault when strace-ing
+  Addresses: https://cygwin.com/pipermail/cygwin/2025-May/258144.html

Reply via email to