[8/8] add non-stop test that stresses thread starvation issues

Message ID 551D57CC.9050403@gmail.com
State New, archived
Headers

Commit Message

Yao Qi April 2, 2015, 2:53 p.m. UTC
  Hi, Pedro,

On 26/12/14 20:31, Pedro Alves wrote:
> +int
> +main (void)
> +{
> +  int res;
> +  int i;
> +
> +  alarm (60);

Is there any reason to call alarm here?  It causes some fails on
arm-linux, that is, the board is slow, and alarm is triggered.
Then thread is disappeared and current_thread is set to NULL.
GDB/GDBserver doesn't know about that.  When the inferior memory is
accessed, current_thread is dereferenced, and GDBserver is crashed.

How about removing it?
  

Comments

Pedro Alves April 6, 2015, 11:26 a.m. UTC | #1
On 04/02/2015 03:53 PM, Yao Qi wrote:
> Hi, Pedro,
> 
> On 26/12/14 20:31, Pedro Alves wrote:
>> +int
>> +main (void)
>> +{
>> +  int res;
>> +  int i;
>> +
>> +  alarm (60);
> 
> Is there any reason to call alarm here?

Yes, the test runs forever otherwise.  See:

  https://sourceware.org/gdb/wiki/GDBTestcaseCookbook#Don.27t_write_tests_that_run_forever

How about fixing this like attach-many-short-lived-threads.exp was
fixed here:

  https://sourceware.org/ml/gdb-patches/2015-02/msg00152.html

?

> It causes some fails on
> arm-linux, that is, the board is slow, and alarm is triggered.
> Then thread is disappeared and current_thread is set to NULL.
> GDB/GDBserver doesn't know about that.  When the inferior memory is
> accessed, current_thread is dereferenced, and GDBserver is crashed.

Sounds like we should have a test that explicitly covers that.
GDBserver shouldn't crash.
  

Patch

diff --git a/gdb/testsuite/gdb.threads/non-stop-fair-events.c 
b/gdb/testsuite/gdb.threads/non-stop-fair-events.c
index 6a9d31d..8ce8fe8 100644
--- a/gdb/testsuite/gdb.threads/non-stop-fair-events.c
+++ b/gdb/testsuite/gdb.threads/non-stop-fair-events.c
@@ -64,8 +64,6 @@  main (void)
    int res;
    int i;

-  alarm (60);
-
    signal (SIGUSR1, handler);

    for (i = 0; i < NUM_THREADS; i++)