aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2018-04-10 15:00:39 +0100
committerPedro Alves <palves@redhat.com>2018-04-10 15:00:39 +0100
commitf50d8a2eaea045cd6e9b8d6d5cf8da55e2047ffb (patch)
tree98358cbad05952204e592ca2646c77b810237541 /gdb
parent731f534f918cfaa35c20b5eb6220a8eba4819f04 (diff)
downloadgdb-f50d8a2eaea045cd6e9b8d6d5cf8da55e2047ffb.zip
gdb-f50d8a2eaea045cd6e9b8d6d5cf8da55e2047ffb.tar.gz
gdb-f50d8a2eaea045cd6e9b8d6d5cf8da55e2047ffb.tar.bz2
Fix gdb.base/fork-running-state.exp race
On my multi-target branch I was occasionaly seeing a FAIL like this: (gdb) PASS: gdb.base/fork-running-state.exp: detach-on-fork=off: follow-fork=parent: non-stop: kill parent [Inferior 2 (process 32672) exited normally] kill inferior 2 warning: Inferior ID 2 is not running. (gdb) FAIL: gdb.base/fork-running-state.exp: detach-on-fork=off: follow-fork=parent: non-stop: kill child (the program exited) ... other similar fails ... Turns out to be a testcase bug/race. A tweak like this increases the changes of hitting the race substancially: --- a/gdb/testsuite/gdb.base/fork-running-state.c +++ b/gdb/testsuite/gdb.base/fork-running-state.c @@ -29,7 +29,7 @@ fork_child (void) { while (1) { - sleep (1); + usleep (100); The testcase has two processes, parent and child fork. The problem is that the child exits itself if it notices the parent is gone, but the testcase .exp does not expect that. I first wrote a patch that handled the different combinations of non-stop/detach-on-fork/follow-fork/schedule-multiple, making the .exp file know when to expect the child to exit itself vs when to kill it explicitly, but the result was that the code to kill the parent and child was getting about as large as the test code that is the actual point of the testcase, above the kills. So I scratched that approach and came up with a simpler patch -- simply make the child not exit itself when the parent exits. The .exp file is going to kill both parent and child explicitly, and, main() already calls alarm() as a safeguard. I don't think we lose anything. gdb/testsuite/ChangeLog: 2018-04-10 Pedro Alves <palves@redhat.com> * gdb.base/fork-running-state.c (fork_child): Don't exit if parent exits. Instead loop running forever. (fork_parent): Run forever too.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.base/fork-running-state.c20
2 files changed, 10 insertions, 16 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index d123a3a..5dd0553 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2018-04-10 Pedro Alves <palves@redhat.com>
+
+ * gdb.base/fork-running-state.c (fork_child): Don't exit if parent
+ exits. Instead loop running forever.
+ (fork_parent): Run forever too.
+
2018-04-07 Simon Marchi <simon.marchi@polymtl.ca>
* gdb.mi/mi-stack.exp (test_stack_frame_listing): Use
diff --git a/gdb/testsuite/gdb.base/fork-running-state.c b/gdb/testsuite/gdb.base/fork-running-state.c
index 233b515..8ea4739 100644
--- a/gdb/testsuite/gdb.base/fork-running-state.c
+++ b/gdb/testsuite/gdb.base/fork-running-state.c
@@ -28,30 +28,18 @@ static int
fork_child (void)
{
while (1)
- {
- sleep (1);
-
- /* Exit if GDB kills the parent. */
- if (getppid () != save_parent)
- break;
- if (kill (getppid (), 0) != 0)
- break;
- }
+ pause ();
return 0;
}
-/* The fork parent. Just runs forever waiting for the child to
- exit. */
+/* The fork parent. Just runs forever. */
static int
fork_parent (void)
{
- if (wait (NULL) == -1)
- {
- perror ("wait");
- return 1;
- }
+ while (1)
+ pause ();
return 0;
}