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

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