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

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