From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by sourceware.org (Postfix) with ESMTPS id 989773851C10 for ; Thu, 14 May 2020 18:58:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 989773851C10 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=alves.ped@gmail.com Received: by mail-wm1-f68.google.com with SMTP id g14so15002876wme.1 for ; Thu, 14 May 2020 11:58:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=FcLC82K7kp5087t2Y7ySQQpyEzZPGX5bJmo5ujXmRR4=; b=E41HXhpLd/3zqQOtGbvBW8SNVDIGKJqqvRl+d7RQK2GSa3zpCU3VGBTJa+akxbLQvX AtE5lZlNUrkhNlOOwVxpNDmERPLzhvrwz9lGxNoxBXwTSJpdik9FQJYYEk+BhFOwU4ub LRFuRllJiqIxRT93r1+0/9ZqRUiHkS+HDHlnXMXY92V5StvjH9NGRCuMhkrFLKuchVaz EggpxtpEk3WZMVw6Hjvy8izCW1PR8keSESXeKZTor3BGmzYoo1+b8hBGP8VnLu/+gjFF z+LKLRt3bPfd1R8lErJZoCmSFukwqEGLEF6lpdhRheEJkl4N2tSQ/mvvDz+8b9GjVlea Pn0g== X-Gm-Message-State: AGi0PubpeCvuIzqqMG9JHE0iDmkB5n4oAIaD2eScSVWETymKGDfuf82I dqZd514qGq80qOZpSEkXObmuAKK1ZgBS7A== X-Google-Smtp-Source: APiQypLunksA7q4UuRqkWRziBc95gIxYEX7KmzWTCGC5GQ538mg5fUks5sr8msiT/ax89PkOavL47g== X-Received: by 2002:a7b:c205:: with SMTP id x5mr28952370wmi.135.1589482724686; Thu, 14 May 2020 11:58:44 -0700 (PDT) Received: from ?IPv6:2001:8a0:f909:7b00:56ee:75ff:fe8d:232b? ([2001:8a0:f909:7b00:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id f5sm5479267wro.18.2020.05.14.11.58.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 May 2020 11:58:43 -0700 (PDT) Subject: Re: [PATCH v8 6/6] gdb/infrun: handle already-exited threads when attempting to stop To: "Aktemur, Tankut Baris" , Tom de Vries , "gdb-patches@sourceware.org" References: <20200513205338.14233-1-palves@redhat.com> <20200513205338.14233-7-palves@redhat.com> <0d00b418-3c5f-4a8c-12dd-eeee8ad12b6b@suse.de> From: Pedro Alves Message-ID: <4ade3da1-a8cd-ba29-80da-f5e742f7b52a@palves.net> Date: Thu, 14 May 2020 19:58:42 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 May 2020 18:58:48 -0000 On 5/14/20 7:54 PM, Aktemur, Tankut Baris wrote: > On Thursday, May 14, 2020 8:00 PM, Tom de Vries wrote: >> On 13-05-2020 22:53, Pedro Alves via Gdb-patches wrote: >>> + set testpid($num) [get_integer_valueof "pid" -1] >> >> I'm running into: >> ... >> ERROR: tcl error sourcing >> /data/gdb_versions/devel/src/gdb/testsuite/gdb.multi/multi-kill.exp. >> ERROR: can't set "testpid(1)": variable isn't array >> while executing >> "set testpid($num) [get_integer_valueof "pid" -1]" > > I'm not able to reproduce this problem. The test runs fine on my system > with 58 expected passes and no failures. Could it be related to the tcl > version? It's related to testcase run order, and the fact that global variables can leak between testcases. > > As a rough guess, could you try the patch below to initialize the array > variable? > > diff --git a/gdb/testsuite/gdb.multi/multi-kill.exp b/gdb/testsuite/gdb.multi/multi-kill.exp > index ce6075045fc..a21f8a78b0d 100644 > --- a/gdb/testsuite/gdb.multi/multi-kill.exp > +++ b/gdb/testsuite/gdb.multi/multi-kill.exp > @@ -70,6 +70,7 @@ proc start_inferior {num} { > # Sufficient inferiors to make sure that at least some other inferior > # is killed while we're handling a killed event. > set NUM_INFS 10 > +array set testpid {} That's not sufficient, because the variable can leak to other tests. For example: $ runtest gdb.threads/check-libthread-db.exp gdb.multi/multi-kill.exp Running /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.multi/multi-kill.exp ... Running /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.threads/check-libthread-db.exp ... ERROR: tcl error sourcing /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.threads/check-libthread-db.exp. ERROR: can't set "testpid": variable is array while executing "set testpid [spawn_id_get_pid $test_spawn_id]" ("uplevel" body line 8) This works for me. >From 96aa00638e9a1201874e316ad53c38614da8cc04 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 14 May 2020 19:07:35 +0100 Subject: [PATCH] Fix global variable collision in gdb.multi/multi-kill.exp gdb/testsuite/ChangeLog: 2020-05-14 Pedro Alves * gdb.multi/multi-kill.exp: Wrap in namespace. (start_inferior): Add TESTPID parameter. Use it instead of the testpid global. (top level): Define empty TESTPID array, and pass it down to start_inferior. --- gdb/testsuite/gdb.multi/multi-kill.exp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/gdb/testsuite/gdb.multi/multi-kill.exp b/gdb/testsuite/gdb.multi/multi-kill.exp index ce6075045fc..03bf8449cf8 100644 --- a/gdb/testsuite/gdb.multi/multi-kill.exp +++ b/gdb/testsuite/gdb.multi/multi-kill.exp @@ -39,11 +39,15 @@ save_vars { GDBFLAGS } { clean_restart ${binfile} } +# Wrap the entire test in a namespace to avoid contaminating other tests. +namespace eval $testfile { + # Start inferior NUM and record its PID in the TESTPID array. -proc start_inferior {num} { +proc start_inferior {num testpid} { with_test_prefix "start_inferior $num" { - global testpid binfile srcfile + upvar $testpid tpid + global binfile srcfile if {$num != 1} { gdb_test "add-inferior" "Added inferior .*" \ @@ -58,8 +62,8 @@ proc start_inferior {num} { gdb_run_cmd gdb_test "" ".*reakpoint .*, initialized .*${srcfile}.*" "run" - set testpid($num) [get_integer_valueof "pid" -1] - if {$testpid($num) == -1} { + set tpid($num) [get_integer_valueof "pid" -1] + if {$tpid($num) == -1} { return -1 } @@ -71,8 +75,11 @@ proc start_inferior {num} { # is killed while we're handling a killed event. set NUM_INFS 10 +# The array holding each inferior's PID, indexed by inferior number. +array set testpid {} + for {set i 1} {$i <= $NUM_INFS} {incr i} { - if {[start_inferior $i] < 0} { + if {[start_inferior $i testpid] < 0} { return -1 } } @@ -125,3 +132,5 @@ for {set i 2} {$i <= $NUM_INFS} {incr i} { "continue to SIGKILL" } } + +} base-commit: a05575d39a5348bd9979fc09e658a03ff22722b9 -- 2.14.5