diff mbox

[OBV] Testsuite: Ensure interrupt-daemon-attach doesn't run forever

Message ID 20190327115023.8808-1-alan.hayward@arm.com
State New
Headers show

Commit Message

Alan Hayward March 27, 2019, 11:50 a.m. UTC
[Pushed because this was slowing down the Aarch64 buildbot.
 Sergio - it's probably worth checking if there are similar hanging processes on
 the other buildslave machines.]

Looking at the AArch64 buildbot, I noticed about two dozen old instances of
interrupt-daemon-attach taking up a full 100% cpu each.

If the test fails then the test binary relies on an alarm to ensure it dies
after 60 seconds.

As per the Linux man page for alarm:
  Alarms created by alarm() ... are not inherited by children created via fork.

Update the test to add an alarm in the child and also put a sleep in the
child loop so it does not constantly consume cpu.

Note I haven't managed to re-create why the test failed.  This fix will just
stop it hanging and consuming cpu when it does.

gdb/testsuite/ChangeLog:

2019-03-27  Alan Hayward  <alan.hayward@arm.com>

	* gdb.base/interrupt-daemon-attach.c (main): Add alarm and sleep
	in child.
---
 gdb/testsuite/gdb.base/interrupt-daemon-attach.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Sergio Durigan Junior March 27, 2019, 6:44 p.m. UTC | #1
On Wednesday, March 27 2019, Alan Hayward wrote:

> [Pushed because this was slowing down the Aarch64 buildbot.
>  Sergio - it's probably worth checking if there are similar hanging processes on
>  the other buildslave machines.]

Thanks for the heads up, Alan.

I see pending builds on the x86_64 builders (and a few more), but I'll
leave them running for now and wait.  Hopefully in a few days things
should be back to normal.

Thanks,

> Looking at the AArch64 buildbot, I noticed about two dozen old instances of
> interrupt-daemon-attach taking up a full 100% cpu each.
>
> If the test fails then the test binary relies on an alarm to ensure it dies
> after 60 seconds.
>
> As per the Linux man page for alarm:
>   Alarms created by alarm() ... are not inherited by children created via fork.
>
> Update the test to add an alarm in the child and also put a sleep in the
> child loop so it does not constantly consume cpu.
>
> Note I haven't managed to re-create why the test failed.  This fix will just
> stop it hanging and consuming cpu when it does.
>
> gdb/testsuite/ChangeLog:
>
> 2019-03-27  Alan Hayward  <alan.hayward@arm.com>
>
> 	* gdb.base/interrupt-daemon-attach.c (main): Add alarm and sleep
> 	in child.
> ---
>  gdb/testsuite/gdb.base/interrupt-daemon-attach.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/testsuite/gdb.base/interrupt-daemon-attach.c b/gdb/testsuite/gdb.base/interrupt-daemon-attach.c
> index 5dc84438dc..e8dddf81b4 100644
> --- a/gdb/testsuite/gdb.base/interrupt-daemon-attach.c
> +++ b/gdb/testsuite/gdb.base/interrupt-daemon-attach.c
> @@ -43,6 +43,7 @@ main ()
>        break;
>  
>      default:
> +      /* In parent process.  */
>        while (1)
>  	{
>  	  marker ();
> @@ -50,12 +51,18 @@ main ()
>  	}
>      }
>  
> +  /* In child process.  */
> +
> +  /* Alarms are not inherited by child processes. Set the alarm again to stop
> +     the test case running forever.  */
> +  alarm (60);
> +
>    /* Detach from controlling terminal.  */
>    if (setsid () == (pid_t) -1)
>      return 1;
>  
> -  for (;;)
> -    ;
> +  while (1)
> +    usleep (1000);
>  
>    return 0;
>  }
> -- 
> 2.20.1 (Apple Git-117)
diff mbox

Patch

diff --git a/gdb/testsuite/gdb.base/interrupt-daemon-attach.c b/gdb/testsuite/gdb.base/interrupt-daemon-attach.c
index 5dc84438dc..e8dddf81b4 100644
--- a/gdb/testsuite/gdb.base/interrupt-daemon-attach.c
+++ b/gdb/testsuite/gdb.base/interrupt-daemon-attach.c
@@ -43,6 +43,7 @@  main ()
       break;
 
     default:
+      /* In parent process.  */
       while (1)
 	{
 	  marker ();
@@ -50,12 +51,18 @@  main ()
 	}
     }
 
+  /* In child process.  */
+
+  /* Alarms are not inherited by child processes. Set the alarm again to stop
+     the test case running forever.  */
+  alarm (60);
+
   /* Detach from controlling terminal.  */
   if (setsid () == (pid_t) -1)
     return 1;
 
-  for (;;)
-    ;
+  while (1)
+    usleep (1000);
 
   return 0;
 }