From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 79F313858D39 for ; Sat, 29 Jul 2023 06:25:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 79F313858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id EE3881F385; Sat, 29 Jul 2023 06:25:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1690611949; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bLf5cg+BDUThDu3tyfeMhnYbvS3hmi4Wdy0Fpy5Tims=; b=TR0oczDEOmXODn2e+v4ki1WO9FjYTawNUYdVMKcHkRT/jkmcXh7Zcgs8wp1C75SG1ekvc5 efE8VFeVVlpb45O2ESBpUaWGYohW3ZoQou+Pd8US6tiJ7IfI4XqkDgTal3rLqfu4MEQHMw kieRL7ivrhFi7bURcnmGIYpf5Ru7nPc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1690611949; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bLf5cg+BDUThDu3tyfeMhnYbvS3hmi4Wdy0Fpy5Tims=; b=aSf+Z35RBpBYpMOv3ZKoNlZCEFOmTiTzSP/7GF14YzG5Iefe861fq7ljBho4lo2uNNuvT3 2AoRxUrmePiQJQAg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D19E913922; Sat, 29 Jul 2023 06:25:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 39hOMe2wxGRUCAAAMHmgww (envelope-from ); Sat, 29 Jul 2023 06:25:49 +0000 Message-ID: <2ef71a71-35b9-4b8d-fbac-fadb69a01fd1@suse.de> Date: Sat, 29 Jul 2023 08:25:35 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH] Restore previous sigmask in gdb.block_signals Content-Language: en-US To: Tom Tromey , gdb-patches@sourceware.org References: <20230728181011.2651060-1-tromey@adacore.com> From: Tom de Vries In-Reply-To: <20230728181011.2651060-1-tromey@adacore.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,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 7/28/23 20:10, Tom Tromey wrote: > Tom de Vries found a bug where, sometimes, a SIGCHLD would be > delivered to a non-main thread, wreaking havoc. > > The problem is that gdb.block_signals was unblocking the signals it > blocked -- but it was being called from the DAP thread, leading to > SIGCHLD being unblocked there. > > This patch fixes the problem by restoring the previous set of signals > instead. > I've done a build and reg-test on x86_64-linux, no regressions. I also build this in combination with the assert patch mentioned in the PR, and ran the dap tests 50 times, and the assert no longer triggers. Also, the patch LGTM. I had a bit of trouble parsing the commit message, I'd suggest for instance instead: ... The problem is that gdb.block_signals after first blocking a set of signals, then unblocked the same set rather than restoring the initial situation. This function being called from the DAP thread lead to SIGCHLD being unblocked there. ... Tested-by: Tom de Vries Reviewed-By: Tom de Vries Thanks, - Tom > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30680 > --- > gdb/python/lib/gdb/__init__.py | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py > index 98aadb1dfea..b3124369fe8 100644 > --- a/gdb/python/lib/gdb/__init__.py > +++ b/gdb/python/lib/gdb/__init__.py > @@ -271,11 +271,11 @@ def blocked_signals(): > return > > to_block = {signal.SIGCHLD, signal.SIGINT, signal.SIGALRM, signal.SIGWINCH} > - signal.pthread_sigmask(signal.SIG_BLOCK, to_block) > + old_mask = signal.pthread_sigmask(signal.SIG_BLOCK, to_block) > try: > yield None > finally: > - signal.pthread_sigmask(signal.SIG_UNBLOCK, to_block) > + signal.pthread_sigmask(signal.SIG_SETMASK, old_mask) > > > class Thread(threading.Thread):