From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by sourceware.org (Postfix) with ESMTPS id 805D5386FC22 for ; Mon, 14 Jun 2021 23:35:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 805D5386FC22 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f48.google.com with SMTP id c5so16200105wrq.9 for ; Mon, 14 Jun 2021 16:35:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=HNoHlgwE8fMCs4wNMh70zjByOGnvlwPw9SNBYInPjoA=; b=Qw1krQoJecI6fHEXfBT5niuyxZOEEr+RPa+H/2HYLDEIeAHrvuUlIAJEgGhEZfdfG+ vMN1gB518TmJ6mrFSCTwUjk77ymzLPVIdedp9jEQKmQWRKKqj6vCa97nMczxBacwFJEa RnPH1fjRK8LF3Nn8MA++JIypejdd7JB9sFwgirI4IAQWX173qgbMnetVvSk4WFYcSlnR xiiocXD3Txsbz1cUeMZfwNNjCWwSAdnYOge1ICmcbzDJjdm1DCRrBKihfm1rTKakfsp6 hEF2hsJJ6KkPWLHFjYHzsL2IsSaduDlDAe7mi6Cn/ANSA59O2c3IhDjtsU7r8MsqFg6f 3VWA== X-Gm-Message-State: AOAM530UNq9lWtNMoyawvihuu0kMV5Udt5GWK9sjNwRIq3K+urV+5OCG 3wLtGQekhzpEiLHi6TGKTvyU8vCrOBjF/Q== X-Google-Smtp-Source: ABdhPJwVzfQlHExwpfYfOytnRyR4BG1LEA5DG2OBH+9jt3bnHkiui+4P+aZTK8N30Wi3i44vPkMnxA== X-Received: by 2002:a5d:6382:: with SMTP id p2mr22269218wru.338.1623713718785; Mon, 14 Jun 2021 16:35:18 -0700 (PDT) Received: from ?IPv6:2001:8a0:f932:6a00:6b6e:c7b6:c5a7:aac3? ([2001:8a0:f932:6a00:6b6e:c7b6:c5a7:aac3]) by smtp.gmail.com with ESMTPSA id k12sm724247wmr.2.2021.06.14.16.35.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Jun 2021 16:35:17 -0700 (PDT) Subject: Re: [PATCH] Fix gdb crash due to SIGPIPE when the compile command fails From: Pedro Alves To: Tom Tromey , Bernd Edlinger Cc: "gdb-patches@sourceware.org" References: <87tumgp1ob.fsf@tromey.com> <87zgw5oijf.fsf@tromey.com> Message-ID: <6256676d-b41a-02ef-22a4-e5150077c0e8@palves.net> Date: Tue, 15 Jun 2021 00:35:16 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <87zgw5oijf.fsf@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Mon, 14 Jun 2021 23:35:22 -0000 On 2021-06-04 2:39 p.m., Tom Tromey wrote: >>>>>> "Bernd" == Bernd Edlinger writes: > > Bernd> I believe it is right to avoid the SIGPIPE before calling the plugin, > Bernd> instead of doing that in gcc-trunk, since we don't know which version > Bernd> we will be calling, and all versions I tried have failed like this. > > That seems fine, but I think it would be better to install the handler > just when working with the plugin, and then uninstall it afterward, sort > of like what class scoped_ignore_sigttou does. One thing I dislike here (and also about scoped_ignore_sigttou), is that the signal disposition is process-wide. If we happen to have multiple threads that need to ignore the signal changing the disposition like that, then they may race. We can fix that by making the ignoring be per-thread instead by using sigprocmask + sigtimedwait. We can also introduce a generic scoped_ignore_signal so that both scoped_ignore_sigttou and scoped_ignore_pipe (and whatever other similar signal we may need to ignore) share the same code. I gave it a quick try. See the 4 patches at the top of the users/palves/scoped_ignore_signal branch. This was something that I've thought before about doing for SIGTTOU to be honest. Seeing it being copied over to SIGPIPE was simply the trigger that made me actually give it a try. WDYT? Pedro Alves