https://gcc.gnu.org/g:cd04a57f7d0fab6c0c5bb49cd88f33d43c848a8b

commit r17-6847-gcd04a57f7d0fab6c0c5bb49cd88f33d43c848a8b
Author: John David Anglin <[email protected]>
Date:   Mon Nov 30 10:08:05 2026 -0500

    libstdc++: Close remote target on eof and batch match in gdb-test.exp
    
    In gdb-test.exp, gdb-test and gdb_batch_check lacked eof clauses when
    waiting on GDB, and gdb_batch_check returned without closing the target
    connection upon matching the expected pattern.  Over large testsuite runs
    this leaks file descriptors and PTYs, which triggers a bug in Tcl/expect
    on big-endian targets and causes cascading timeouts that break the rest
    of the testsuite.
    
    Handle eof cleanly by calling remote_close target, and close the target
    connection before returning from gdb_batch_check on a match.
    
    2026-11-29  John David Anglin  <[email protected]>
    
    libstdc++-v3/ChangeLog:
    
            * testsuite/lib/gdb-test.exp (gdb-test): Handle eof and call
            remote_close target.
            (gdb_batch_check): Call remote_close target on pattern match and
            handle eof.

Diff:
---
 libstdc++-v3/testsuite/lib/gdb-test.exp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/libstdc++-v3/testsuite/lib/gdb-test.exp 
b/libstdc++-v3/testsuite/lib/gdb-test.exp
index e80bbd8d11aa..6a0994b7edfc 100644
--- a/libstdc++-v3/testsuite/lib/gdb-test.exp
+++ b/libstdc++-v3/testsuite/lib/gdb-test.exp
@@ -261,6 +261,12 @@ proc gdb-test { marker {selector {}} {load_xmethods 0} } {
            exp_continue
        }
 
+       eof {
+           unsupported "$testname"
+           remote_close target
+           return
+       }
+
        timeout {
            unsupported "$testname"
            remote_close target
@@ -287,6 +293,7 @@ proc gdb_batch_check {command pattern} {
 
     remote_expect target [timeout_value] {
        -re $pattern {
+           remote_close target
            return 1
        }
 
@@ -295,6 +302,11 @@ proc gdb_batch_check {command pattern} {
            exp_continue
        }
 
+       eof {
+           remote_close target
+           return 0
+       }
+
        timeout {
            remote_close target
            return 0

Reply via email to