From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 9C44F3858D39 for ; Sat, 29 Jul 2023 06:37:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9C44F3858D39 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 8398D1F385; Sat, 29 Jul 2023 06:37:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1690612678; 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=SVHcXMLwAv0Z1ZfHRCV7bDc3pBmZgsCsphP5tmEpfh8=; b=jdIOByy9P5TRvh2u+c/K4OtejghNtCjbUCAJ5p0acKfe0RTOYkjeXwXAh7zajc6ztKNdyF oqs1x3UI/RJO4x95gnkZWaUjiB7hyAyr9ExLaB8C+/uU+CiEcDvd5QZltkyfJaV7jEuBnd JFSYdVUefOB7bXdO0V+lf7GB+PmLA4A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1690612678; 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=SVHcXMLwAv0Z1ZfHRCV7bDc3pBmZgsCsphP5tmEpfh8=; b=xCKR74fyR7AhCpruole1G8uOjxf3qDO8Uru5j1pRAmLtw28A87dzDr1BKESnnj53JD3z4b RZp2kzBwY1ZutlCA== 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 67C3213922; Sat, 29 Jul 2023 06:37:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id HuyHF8azxGRhDAAAMHmgww (envelope-from ); Sat, 29 Jul 2023 06:37:58 +0000 Message-ID: <651d15ef-ff0e-7c80-7d5e-f4ade2f6620d@suse.de> Date: Sat, 29 Jul 2023 08:37:44 +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> <2ef71a71-35b9-4b8d-fbac-fadb69a01fd1@suse.de> From: Tom de Vries In-Reply-To: <2ef71a71-35b9-4b8d-fbac-fadb69a01fd1@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00,BODY_8BITS,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/29/23 08:25, Tom de Vries via Gdb-patches wrote: > 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, I build with -fsanitize=thread and tested the dap tests, that's also clean now. Thanks, - Tom > 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): >