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