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

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