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

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