From patchwork Tue Apr 7 10:10:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 6040 Received: (qmail 91070 invoked by alias); 7 Apr 2015 10:10:38 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 91054 invoked by uid 89); 7 Apr 2015 10:10:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f46.google.com Received: from mail-pa0-f46.google.com (HELO mail-pa0-f46.google.com) (209.85.220.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 07 Apr 2015 10:10:34 +0000 Received: by patj18 with SMTP id j18so73928428pat.2 for ; Tue, 07 Apr 2015 03:10:32 -0700 (PDT) X-Received: by 10.70.101.65 with SMTP id fe1mr35525777pdb.54.1428401432662; Tue, 07 Apr 2015 03:10:32 -0700 (PDT) Received: from E107787-LIN (gcc1-power7.osuosl.org. [140.211.15.137]) by mx.google.com with ESMTPSA id x9sm7403507pbt.68.2015.04.07.03.10.30 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 07 Apr 2015 03:10:31 -0700 (PDT) From: Yao Qi To: Pedro Alves Cc: Yao Qi , gdb-patches@sourceware.org Subject: Re: [PATCH 8/8] add non-stop test that stresses thread starvation issues References: <1419625871-28848-1-git-send-email-palves@redhat.com> <1419625871-28848-9-git-send-email-palves@redhat.com> <551D57CC.9050403@gmail.com> <55226D5D.3020200@redhat.com> Date: Tue, 07 Apr 2015 11:10:28 +0100 In-Reply-To: <55226D5D.3020200@redhat.com> (Pedro Alves's message of "Mon, 06 Apr 2015 12:26:21 +0100") Message-ID: <86d23gxn8r.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes Pedro Alves writes: > 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 > > ? > OK, how about the patch below? >> 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. Yes, let me think about a test case to cover that. diff --git a/gdb/testsuite/gdb.threads/non-stop-fair-events.c b/gdb/testsuite/gdb.threads/non-stop-fair-events.c index 6a9d31d..f82c366 100644 --- a/gdb/testsuite/gdb.threads/non-stop-fair-events.c +++ b/gdb/testsuite/gdb.threads/non-stop-fair-events.c @@ -22,6 +22,9 @@ #define NUM_THREADS 10 const int num_threads = NUM_THREADS; +/* Allow for as much timeout as DejaGnu wants, plus a bit of + slack. */ +#define SECONDS (TIMEOUT + 20) pthread_t child_thread[NUM_THREADS]; volatile pthread_t signal_thread; @@ -53,6 +56,8 @@ child_function (void *arg) while (1) { + /* Reset the timer before going to INF_LOOP. */ + alarm (SECONDS); INF_LOOP; /* set thread breakpoint here */ loop_broke (); } @@ -64,8 +69,6 @@ main (void) int res; int i; - alarm (60); - signal (SIGUSR1, handler); for (i = 0; i < NUM_THREADS; i++) @@ -76,6 +79,8 @@ main (void) while (1) { pthread_kill (signal_thread, SIGUSR1); /* set kill breakpoint here */ + /* Reset the timer before going to INF_LOOP. */ + alarm (SECONDS); INF_LOOP; loop_broke (); } diff --git a/gdb/testsuite/gdb.threads/non-stop-fair-events.exp b/gdb/testsuite/gdb.threads/non-stop-fair-events.exp index 9b7b9ca..e2d3f7d 100644 --- a/gdb/testsuite/gdb.threads/non-stop-fair-events.exp +++ b/gdb/testsuite/gdb.threads/non-stop-fair-events.exp @@ -24,7 +24,8 @@ if [target_info exists gdb,nosignals] { return -1 } -if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}] == -1} { +set options { "additional_flags=-DTIMEOUT=$timeout" debug pthreads } +if {[prepare_for_testing "failed to prepare" $testfile $srcfile $options] == -1} { return -1 }