From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2610:1c1:1:606c::19:2]) by sourceware.org (Postfix) with ESMTPS id 6180B3858413 for ; Thu, 25 Nov 2021 00:31:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6180B3858413 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id DF4709A7A8; Thu, 25 Nov 2021 00:31:15 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HzzM750Y5z4hg7; Thu, 25 Nov 2021 00:31:15 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from [10.0.1.4] (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 42E2747DD; Thu, 25 Nov 2021 00:31:15 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <246a50db-b1e8-8548-6f4d-7ed9483c4565@FreeBSD.org> Date: Wed, 24 Nov 2021 16:31:14 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: [PATCH v2 13/13] inf-ptrace: Add an event_pipe to be used for async mode in subclasses. Content-Language: en-US From: John Baldwin To: Andrew Burgess Cc: gdb-patches@sourceware.org References: <20210803185000.22171-1-jhb@FreeBSD.org> <20210803185000.22171-14-jhb@FreeBSD.org> <20211124153018.GM2662946@redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1637800275; 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=B9o/mX01W6oKt8I9D0XIB6TSpK4OImS4Xu9VKbEFtpg=; b=whQe01lPy0zM9U9hCtn1aj9PwZi3MfVMy13KjuqyEZIPflidG8isRReA858m2bDgfD+GJJ IPTQfgEkq59GdKCzEzgQHWW6MJFzk2e0ioR7B2Goo02fWO/meP7Xh+r2zmnsQ76VmU6Wrg BA0QT3jn80x+K9cTDKP7RkHB12LS61IYQCu6MkO7I8E7Cbkjy96U9IUHsTLuAG2vPAuBzm IX2mtXExlWU8GlR4TThvpCWKj4eVPkjdC2Q54ApJ4o6Lz/Oyf/W+QBJCvVuZJHgxANiYHE 4otyq+hxFi1n28iW+j7BBQ/VqjwkaksVKR1e+py2gFHlkfSxKDu6avTroK53nw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1637800275; a=rsa-sha256; cv=none; b=K+TyfzEZkF5o0a/JLI22v0IzMdJ5kUVvniJ/rZ1Q8oUHG2RvZKoJj6vAa8TVKcdoFYy1eY Zbx9klY8X2GI7ClYODChaTC1/C46egOOTGez5OF17dAvQs9n1jghv8QufO9O7xTTNalnMx gFoKrL7Mc6UuntQmjYq/FHQBM1enLoG4zDh0JMbMyVrXS+ab7oessaQUN6431cbD88vX5b M8gaV1J9HqVa7f9TfBfApEDjOaiyLd4ecfYp+oH78Q2d4u3mDXOkZq1JvOJYdjBWWWyAlk /ombhhmFaK/q0idf+GaM0KTQrVvijrvjit6hArswJra6NbaWf53vEBtpJydepA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Thu, 25 Nov 2021 00:31:19 -0000 On 11/24/21 4:14 PM, John Baldwin wrote: > On 11/24/21 7:30 AM, Andrew Burgess wrote: >> * John Baldwin [2021-08-03 11:50:00 -0700]: >>> /* target_async implementation. */ >>> >>> void >>> linux_nat_target::async (int enable) >>> { >>> + if ((enable != 0) == is_async_p ()) >>> + return; >>> + >>> + sigset_t prev_mask; >>> + >>> + /* Block child signals while we create/destroy the pipe, as their >>> + handler writes to it. */ >>> + block_child_signals (&prev_mask); >> >> Not your problem as it was a bug that existed before, but if we ever >> throw an error below then the signal mask would not be restored. We >> should really switch to using a new scoped_block_child_signals class. > > This one might be a bit subtle as block_child_signals has the side effect > of updating the global variable blocked_mask. However, this code seem to > have rotted a bit. blocked_mask is set to empty in _initialize_linux_nat, > then the first call to block_child_signals sets SIGCLD (which is then > never un-set as far as I can see) before using sigprocmask to block > SIGCLD. I don't know if at some point in time it used to be removed > from blocked_mask? Looks like the LinuxThreads bits might have messed > with blocked_mask in the past (but that code has been removed). > > I do think using gdb::block_signals() might be ok (even if a bit > heavyweight as it blocks multiple signals), and can probably be used to > replace all the uses of block_child_signals. That's probably best as a > separate cleanup though. Actually, while looking at this further, I think adapting this specific place in ::async is ok, but I'm inclined to leave the other places in linux-nat.c alone. I'll roll that into this change. -- John Baldwin