Blame SOURCES/gdb-rhbz1941080-fix-gdbserver-hang.patch

132741
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
132741
From: Kevin Buettner <kevinb@redhat.com>
132741
Date: Fri, 19 Mar 2021 11:07:11 -0700
132741
Subject: gdb-rhbz1941080-fix-gdbserver-hang.patch
132741
132741
;; Backport change which fixes gdbserver testing hang on f34 and rawhide.
132741
132741
Fix potential hang during gdbserver testing
132741
132741
We're currently seeing testing of native-extended-gdbserver hang while
132741
testing the x86_64 architecture on both Fedora 34 and Fedora Rawhide.
132741
The test responsible for the hang is gdb.threads/fork-plus-threads.exp.
132741
132741
While there is clearly a problem/bug with this test on F34 and
132741
Rawhide, it's also the case that testing should not hang.  This commit
132741
prevents the hang by waiting with the "-nowait" flag in
132741
close_gdbserver.
132741
132741
The -nowait flag is also used in the kill_wait_spawned_process proc in
132741
gdb/testsuite/lib/gdb.exp, so there is precedent for doing this.
132741
132741
There are also 15 other uses of "wait -i" scattered throughout the
132741
test suite.  While it's tempting to change these to also use the
132741
-nowait flag, I think it might be safer to defer doing so until we
132741
actually see a problem.
132741
132741
I've tested this patch on Fedora 32, 33, 34, and Rawhide.  Results are
132741
comparable on Fedora 32 and 33.  On Fedora 34 and Rawhide, with this
132741
commit in place, testing completes when the target_board is
132741
native-extended-gdbserver.  On those OSes, when not using this commit,
132741
testing usually hangs due to a problem with
132741
gdb.threads/fork-plus-threads.exp.  I've also tested on all of the
132741
mentioned OSes with target_board=native-gdbserver; for that testing,
132741
I achieved comparable results over a number of runs.  (Unfortunately
132741
results are rarely identical due to racy tests.)
132741
132741
gdb/testsuite/ChangeLog:
132741
132741
	* lib/gdbserver-support.exp (gdbserver_exit): Use the
132741
	"-nowait" flag when waiting for gdbserver to exit.
132741
132741
diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp
132741
--- a/gdb/testsuite/lib/gdbserver-support.exp
132741
+++ b/gdb/testsuite/lib/gdbserver-support.exp
132741
@@ -418,7 +418,12 @@ proc close_gdbserver {} {
132741
     verbose "Quitting GDBserver"
132741
 
132741
     catch "close -i $server_spawn_id"
132741
-    catch "wait -i $server_spawn_id"
132741
+
132741
+    # If gdbserver misbehaves, and ignores the close, waiting for it
132741
+    # without the -nowait flag will cause testing to hang.  Passing
132741
+    # -nowait makes expect tell Tcl to wait for the process in the
132741
+    # background.
132741
+    catch "wait -nowait -i $server_spawn_id"
132741
     unset server_spawn_id
132741
 }
132741