From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 5A5CE3858C98 for ; Thu, 29 Feb 2024 14:07:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5A5CE3858C98 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5A5CE3858C98 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709215655; cv=none; b=hDDUpo1NWotY8TOHgTiOVF28xC96T55jk25QWCvdaqYOHi7DUhpToFPgbrAo5qKXOEddLBVTFXZ+kaqDbQ6f2WIEIRz0+2w8PJuCboi6RdsTlqw5o3ehOhgLWLnspk1JGSM+tue9mkpB1q7nbD4UO4od0YwQRKfZ5ClVhmTsT2U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709215655; c=relaxed/simple; bh=1N/HZuvc9u/IOnMhmL7MDV+xu9tOHkE5JhcmFzQ0Nec=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:To:From; b=vBnALVXg3bwKNYfMzN+JYgWK8VdRCA0fPlcgUR5uNP8kIDzuGVgEhM4Xv5lGCFDtOr26JlSgSvcqBzu9YKug/svXOXan2+s6zImXa58pdraMT9SeAk1jHCFs3eNw6/QZX6MuLu7zyTW0zC4F3iFmqzCuhAtnKddsKmrO5/3L+OM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 64F5A2212F; Thu, 29 Feb 2024 14:07:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1709215645; h=from:from:reply-to: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=k1dZNRrKqjQuYoztipSidRxQ/EUDv2Pf9cJL6N1088A=; b=GNYiCxnRr/gNuAexJhppWP/e+A7iHO/xQpXRg00qCLnU2buApprGiS52TCi9tdMYQWi6t7 RRCwxPnvQ7v3b4FBowtsDxAmSLbLJOt5KjmFzDangu5NaLuTdpvibXjsMhhk/lY5PGfyFE z13J3q5rRe3HGUpkjIE+D2SCInC2Ck0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1709215645; h=from:from:reply-to: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=k1dZNRrKqjQuYoztipSidRxQ/EUDv2Pf9cJL6N1088A=; b=3RmaJPTgD4hnfp507lFXkRNZxcPbma9RMsqhUfz2nNTnDCW2wBEiEbeldJoFlaPqqfTydo Wb3Qfm+rlQcYfqAg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1709215645; h=from:from:reply-to: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=k1dZNRrKqjQuYoztipSidRxQ/EUDv2Pf9cJL6N1088A=; b=GNYiCxnRr/gNuAexJhppWP/e+A7iHO/xQpXRg00qCLnU2buApprGiS52TCi9tdMYQWi6t7 RRCwxPnvQ7v3b4FBowtsDxAmSLbLJOt5KjmFzDangu5NaLuTdpvibXjsMhhk/lY5PGfyFE z13J3q5rRe3HGUpkjIE+D2SCInC2Ck0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1709215645; h=from:from:reply-to: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=k1dZNRrKqjQuYoztipSidRxQ/EUDv2Pf9cJL6N1088A=; b=3RmaJPTgD4hnfp507lFXkRNZxcPbma9RMsqhUfz2nNTnDCW2wBEiEbeldJoFlaPqqfTydo Wb3Qfm+rlQcYfqAg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 4A9A513503; Thu, 29 Feb 2024 14:07:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id oduAEJ2P4GWLGwAAD6G6ig (envelope-from ); Thu, 29 Feb 2024 14:07:25 +0000 Message-ID: Date: Thu, 29 Feb 2024 15:07:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/2] [gdb/dap] Fix stray KeyboardInterrupt after cancel Content-Language: en-US To: Tom Tromey Cc: gdb-patches@sourceware.org References: <20240226115825.29705-1-tdevries@suse.de> <20240226115825.29705-2-tdevries@suse.de> <87o7c0tkk5.fsf@tromey.com> From: Tom de Vries In-Reply-To: <87o7c0tkk5.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Authentication-Results: smtp-out1.suse.de; none X-Spamd-Result: default: False [-0.54 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; XM_UA_NO_VERSION(0.01)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; BAYES_HAM(-0.45)[78.90%]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-Spam-Level: X-Spam-Score: -0.54 X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,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 List-Id: On 2/28/24 21:12, Tom Tromey wrote: >>>>>> "Tom" == Tom de Vries writes: > > Tom> Fix this by: > Tom> - in CancellationHandler, renaming variable in_flight to in_flight_dap_thread, > Tom> and adding a variable in_flight_gdb_thread to be able to distinguish when > Tom> a request is in flight in the dap thread or the gdb thread. > Tom> - adding a wrapper Cancellable to to deal with cancelling the wrapped > Tom> event > Tom> - using Cancellable in send_gdb and send_gdb_with_response to wrap the posted > Tom> event > Tom> - in CancellationHandler.cancel, only call gdb.interrupt if > Tom> req == self.in_flight_gdb_thread. > > Thanks. I like this patch a lot. > > I have one question about it. > > Tom> + @contextmanager > Tom> + def interruptable_region(self, req): > Tom> + with self.lock: > Tom> + # If the request is cancelled, don't execute the region. > Tom> + while len(self.reqs) > 0 and self.reqs[0] <= req: > Tom> + if heapq.heappop(self.reqs) == req: > Tom> + raise KeyboardInterrupt() > Tom> + # Request is being handled by the gdb thread. > Tom> + self.in_flight_gdb_thread = req > > (see below) > > Tom> + try: > Tom> + # Execute region. This may be interrupted by gdb.interrupt. > Tom> + yield None > Tom> + finally: > Tom> + # Request has been handled by the gdb thread, > Tom> + with self.lock: > Tom> + self.in_flight_gdb_thread = None > Tom> + > > I think it's possible for the interrupt to occur at the marked spot > above -- in_flight_gdb_thread has been set and the lock has been > released. > > However, in this case it seems like in_flight_gdb_thread won't be reset? > > I'm not really sure if this matters. However, wouldn't moving the 'with' > block inside the 'try' definitely fix this? > Done in v3. Thanks, - Tom > Tom