From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id qzsNF+2HpmD5XgAAWB0awg (envelope-from ) for ; Thu, 20 May 2021 12:01:49 -0400 Received: by simark.ca (Postfix, from userid 112) id 4FF671F11C; Thu, 20 May 2021 12:01:49 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 774081E813 for ; Thu, 20 May 2021 12:01:48 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C2535396E866; Thu, 20 May 2021 16:01:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C2535396E866 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1621526507; bh=g3lDFdGxb2cuZ/qb4wAgtoQXWYMQiZKXlYDObkf+Wxg=; h=Subject:To:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=N+2NShBADYU6xI4NMEFcYfsFfYK6tx/UzAfNMdN8YM+Vmw+Y4TCUwmInQWR/gZ9E6 +8QIa8Lj+QDYa9bSLwkAPaLid7G7LZZfXgJtp5OvRY0OkiRgv7q8otkrFMXubXpJ5i U64zHkl3Pv0tVW8w55KMYp6mQ8+JwMpa7HiEEfRs= Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id E8107396B420 for ; Thu, 20 May 2021 16:01:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E8107396B420 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14KFcmQ4069696; Thu, 20 May 2021 12:01:34 -0400 Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com with ESMTP id 38nskttvje-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 May 2021 12:01:34 -0400 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 14KFn9EG030009; Thu, 20 May 2021 16:01:33 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma02dal.us.ibm.com with ESMTP id 38j5xa2vdk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 May 2021 16:01:33 +0000 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 14KG1ULm10945184 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 May 2021 16:01:30 GMT Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4337F6E056; Thu, 20 May 2021 16:01:30 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CBB746E053; Thu, 20 May 2021 16:01:29 +0000 (GMT) Received: from li-e362e14c-2378-11b2-a85c-87d605f3c641.ibm.com (unknown [9.211.90.242]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 20 May 2021 16:01:29 +0000 (GMT) Message-ID: <73bcfb777e72f549218cb431784e103b1831ea30.camel@us.ibm.com> Subject: Re: [PATCH] kill all threadapply processes at end of test To: Pedro Franco de Carvalho , gdb-patches@sourceware.org Date: Thu, 20 May 2021 09:01:29 -0700 In-Reply-To: <875yzflgzs.fsf@linux.ibm.com> References: <87cztn7lk9.fsf@linux.ibm.com> <875yzflgzs.fsf@linux.ibm.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-14.el8) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: K1pWrDhdQFKgIyr8epW99ZFbl_tk5x2a X-Proofpoint-ORIG-GUID: K1pWrDhdQFKgIyr8epW99ZFbl_tk5x2a X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-05-20_04:2021-05-20, 2021-05-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 phishscore=0 priorityscore=1501 malwarescore=0 mlxlogscore=999 mlxscore=0 spamscore=0 bulkscore=0 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105200104 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: , From: Carl Love via Gdb-patches Reply-To: Carl Love Cc: rogealve@br.ibm.com, ulrich.weigand@de.ibm.com, tom@tromey.com, cel@us.ibm.com Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Pedro, Simon, Tom: Here is the updated patch to re-attach the threads and kill them. In this version, I moved the re-attach and kill code to the thr_apply_detach proceedure. This will kill off the detached threads as soon as the test is done. The busy loop runs for a really long time relative to the test. The concern that was raised with the previous version of the patch was the thread re-attach was done after all of the tests were completed. The concern is that it is possible for a detatched thread to finish and have the pid get reused before the code to re-attach and kill it occurs. The result would be attaching to an unrelated pid and killing it. By moving the re-attach code to the proceedure where the detach testing is done reduces the time before killing the process. The original issue was that the detatched processes were left running after the entire testsuite finished. I saw these detached processes running for several minutes after the gdb testsuite finished. Given the time it takes for the busy loop to complete versus the time between the thread being detached and reattached the likely hood of the process finishing and the pid being recycled is extremely small. The other proposal is to use thread barriors rather then the busy loop. As pointed out, this could bread the other tests. The approach has not been implemented so it is not clear if that would be a problem or not. The barrior approach would guarentee that there is no possibility of a pid being recycled, it does make the test code more complex. Do people feel that the re-attach thread and kill it as implemented in this patch is safe enough? Carl ---------------------------------------------------- gdb/testsuite/ChangeLog: 2021-05-20 Carl Love * gdb.threads/threadapply.exp (thr_apply_detach): Add test, gdb_test_multiple, lappend pids to detach_pids. Add foreach i loop on detach_pids, add gdb_test test to attach and kill each pid. --- gdb/testsuite/gdb.threads/threadapply.exp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/gdb/testsuite/gdb.threads/threadapply.exp b/gdb/testsuite/gdb.threads/threadapply.exp index ebc1cf15ad6..be34e38b50d 100644 --- a/gdb/testsuite/gdb.threads/threadapply.exp +++ b/gdb/testsuite/gdb.threads/threadapply.exp @@ -70,6 +70,8 @@ gdb_test "down" "#0.*thread_function.*" "go down and check selected frame" # PR threads/13217. proc thr_apply_detach {thread_set} { + set detach_pids "" + with_test_prefix "thread apply $thread_set" { global binfile global break_line @@ -84,9 +86,29 @@ proc thr_apply_detach {thread_set} { gdb_breakpoint "$break_line" gdb_continue_to_breakpoint "all threads started" + set test "get inferior pid" + set pid -1 + + gdb_test_multiple "info inferior 1" "$test" { + -re "process (\[0-9\]*).*" { + set pid $expect_out(1,string) + pass "$test" + } + } + + lappend detach_pids $pid + gdb_test "thread apply $thread_set detach" "Thread .*" gdb_test "thread" "No thread selected" "switched to no thread selected" } + + # Don't leave detatched threadapply processes running. Reattach and stop + # the processes + foreach i $detach_pids { + # puts $i + gdb_test "attach $i" ".*" "Attach to $i" ".*A program is being debugged already.*" "y" + gdb_test "kill" ".*" "KILL $i" ".*Kill the program being debugged.*" "y" + } } # Test both "all" and a thread list, because those are implemented as -- 2.27.0