From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 8k8xEQ5Bwmb/swsAWB0awg (envelope-from ) for ; Sun, 18 Aug 2024 14:44:30 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=NePD2blk; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 2EFE21E0D0; Sun, 18 Aug 2024 14:44:30 -0400 (EDT) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 14DBC1E08C for ; Sun, 18 Aug 2024 14:44:28 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 785DA3861839 for ; Sun, 18 Aug 2024 18:44:27 +0000 (GMT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 082773858429 for ; Sun, 18 Aug 2024 18:44:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 082773858429 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 082773858429 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724006646; cv=none; b=Vo626ipCd+DfS46e8635Ovhgcshjh6V2cYuQCIJeSP0BbwJSQzfB1iiDRcOiwb+qkZjo7bivqt5w4/mKCDFC9mQiU7Aj0gC7EXi6nMI2yo7qAbkfH0h/OOE5iEsIM5d0G1yj7uPuVcbff0eVe4+9xY7ugfG9fUPeHXRRtWIJy/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724006646; c=relaxed/simple; bh=Lu+feUgQsXX1NAY2P1nF7D/TSbdEo/C7wQA67No1X5g=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=dBLCvYPRrukJcUQBUQXjhPwnspXmLaK8gqzKTUTa82CY9LFZNMvxI/aDyV7ZqoY7z+XxWkzl3CvMj1VyYa78ufh4BqDYlcjSdNhlIpLHObJgyWhDQSId4vepb2/AVC1eltkF+r4OA9nbNYKXDVANYuFwKOVHtVl0stQhUZwRMDk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724006643; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kFUxn1N0F29HP/dLFmIqTq2NqQWa60b8tRYNhfBjipI=; b=NePD2blk1PbFblReQ/Yz8jDoMpHZ5YXC7y3cEFJh6OHwpQO3AlsvpvIxnP5lVU4+tm/t+9 kvof82HQS6nZ7lKkTFAlTy4wdHHX5jujNPPkMV/fFrIUW4b/ZElvFINOVMMv8lrwVn5LOq Z20Sltu7FE2XTK15FJ8vbqCDWsro7sQ= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-665-4beeXQqbMXepqzOFLxQlPQ-1; Sun, 18 Aug 2024 14:44:01 -0400 X-MC-Unique: 4beeXQqbMXepqzOFLxQlPQ-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0E95219560B4; Sun, 18 Aug 2024 18:44:01 +0000 (UTC) Received: from f40-zbm-amd (unknown [10.22.8.12]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A803B30001A1; Sun, 18 Aug 2024 18:43:59 +0000 (UTC) Date: Sun, 18 Aug 2024 11:43:56 -0700 From: Kevin Buettner To: Tom de Vries Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v2] [gdb] Prune inferior after switching inferior Message-ID: <20240818114356.459b48f9@f40-zbm-amd> In-Reply-To: <20240731074605.12070-1-tdevries@suse.de> References: <20240731074605.12070-1-tdevries@suse.de> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On Wed, 31 Jul 2024 09:46:05 +0200 Tom de Vries wrote: > Usually with test-case gdb.python/py-progspace-events.exp I get: > ... > (gdb) inferior 1^M > [Switching to inferior 1 [process 4116] (py-progspace-events)]^M > [Switching to thread 1.1 (Thread 0xf77d0ce0 (LWP 4116))]^M > 28 { /* Nothing. */ }^M > (gdb) PASS: gdb.python/py-progspace-events.exp: inferior 1 > step^M > FreeProgspaceEvent: ^M > do_parent_stuff () at py-progspace-events.c:41^M > 41 ++global_var;^M > (gdb) PASS: gdb.python/py-progspace-events.exp: step > ... > > But occasionally I run into the following FAIL: > ... > (gdb) inferior 1^M > [Switching to inferior 1 [process 5199] (py-progspace-events)]^M > [Switching to thread 1.1 (Thread 0xf77d0ce0 (LWP 5199))]^M > 28 { /* Nothing. */ }^M > (gdb) FreeProgspaceEvent: ^M > FAIL: gdb.python/py-progspace-events.exp: inferior 1 (timeout) > ... > > This is caused by a race between the handling of an event, and the > "inferior 1" command. > > In the passing case, the event is handled first. During which prune_inferiors > is called, but it can't remove inferior 2, because it's still the current one. > > In the failing case, the "inferior 1" command is handled first. Then during > handling of the event, prune_inferiors is called, and it can remove inferior 2 > because it's no longer the current one. > > This looks like a test-case issue to me, but ISTM that we can do better: by > calling prune_inferiors asap, at the end of the "inferior 1" command, we > stabilize the moment when the inferior is removed: > ... > (gdb) inferior 1^M > [Switching to inferior 1 [process 5199] (py-progspace-events)]^M > [Switching to thread 1.1 (Thread 0xf77d0ce0 (LWP 5199))]^M > 28 { /* Nothing. */ }^M > FreeProgspaceEvent: ^M > (gdb) PASS: gdb.python/py-progspace-events.exp: inferior 1 > ... > > This also allows us to simplify the test-case by removing the step command, > which is no longer required to trigger the pruning of the inferior. > > Tested on x86_64-linux. > > PR gdb/31440 > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31440 Approved-by: Kevin Buettner