From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 10B6D38618B6 for ; Sat, 5 Jun 2021 12:04:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 10B6D38618B6 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wm1-x330.google.com with SMTP id l11-20020a05600c4f0bb029017a7cd488f5so7079153wmq.0 for ; Sat, 05 Jun 2021 05:04:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Y4rVv44mPCGj6/Q3j+AAKpbSSZkUDmaP4a9X7lMFJec=; b=d6u0fbThyCh9tLyBunIHSAO4hK+UzHfhUuAReMuRRePlfbxEU0XfdxpzT03IftRe3V TnL2UBgbktefIgXMtvbCh8Kkma3OAE6OrlmR1Bh0Z51g6ITjrYpOYvAg6/zAJ/HBh4y4 YoaHGqgH20NnPDMRsoJarn+HKdZDlZxc+k6lFPbWsWwQAWJ6/I/hM5RRwJMoEwlDWQfh YDkPn6FmmA4yZ/ZCRTbHAmVz0LkSRxDpEDqn/YMoEW3k13QL2IyAcLGy5Zs01Uj9mzBF Z0lRf9di7E4eULO1oBsX6Z3iLLnPUdDVKPSuvYyl7baKYTsaM2HMNvUla44DYOY96aw7 EchA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Y4rVv44mPCGj6/Q3j+AAKpbSSZkUDmaP4a9X7lMFJec=; b=S5uwV20w2xNPf0xivuhKjdvhLf9IBrkIWCHQhR79nVRBtrE4Qpo9JMURWuPgaL20ko +9QQnvvdFPCsXQw/Ak1M8pHS9MAgH47RBIk2dcRotsx+8uYpMdfFnd51y2VtdPpR83pI fg9fSh3ZYcm/FK+Ig9P+mBPlTrB3ckLI5cFG++gnbwNZu1uoib6pmLCfmrfvsVVVJG3+ A11WMW9BAvT9DeAN0GZGa0SVhUqHp9DxjOKb8I5p0gYvj7CCkodT/86F/V9nlUYPfY6p DsnwWmxZB/FkqixlM555/fSZsZII7nU9wBXFPfyDvv8VNlF1PU1ti+ZNXmu0pxeCi5Ld Icpw== X-Gm-Message-State: AOAM531vPKa5peoxHQihxc/0wyRqmCSA88PaY1rWYgFCaCqivo0vv8Tc jPDLXtB5ReKh6iB7TV808TPthA== X-Google-Smtp-Source: ABdhPJyXGV5Hwn8mBbeDFX0CW1xidpqpRhFgixYHKE/m8Y+K3ecKCL/MTZQ74dqg941/QW71dq1DOw== X-Received: by 2002:a05:600c:499a:: with SMTP id h26mr8198489wmp.32.1622894695102; Sat, 05 Jun 2021 05:04:55 -0700 (PDT) Received: from localhost (host109-151-46-70.range109-151.btcentralplus.com. [109.151.46.70]) by smtp.gmail.com with ESMTPSA id z11sm7493907wrt.36.2021.06.05.05.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Jun 2021 05:04:54 -0700 (PDT) Date: Sat, 5 Jun 2021 13:04:53 +0100 From: Andrew Burgess To: Bernd Edlinger Cc: Tom Tromey , "gdb-patches@sourceware.org" Subject: Re: [PATCH] Fix gdb crash due to SIGPIPE when the compile command fails Message-ID: <20210605120453.GR2672@embecosm.com> References: <87tumgp1ob.fsf@tromey.com> <87zgw5oijf.fsf@tromey.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: Linux/5.8.18-100.fc31.x86_64 (x86_64) X-Uptime: 13:03:20 up 17 days, 1:47, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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: Sat, 05 Jun 2021 12:05:06 -0000 * Bernd Edlinger [2021-06-05 13:44:03 +0200]: > On 6/4/21 3:39 PM, 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. > > > > Okay, done, that works for me. > > Is this OK? > > > Thanks > Bernd. > > From 3bb3966601a89c18ea2700c3eae4aa4f4e195269 Mon Sep 17 00:00:00 2001 > From: Bernd Edlinger > Date: Wed, 2 Jun 2021 19:21:15 +0200 > Subject: [PATCH] Fix gdb crash due to SIGPIPE when the compile command fails > > Due to the SIGPIPE the gdb process is killed here, which is > not helpful. > > 2021-06-02 Bernd Edlinger > > * compile/compile.c (compile_to_object): Ignore SIGPIPE before calling > the plugin. > --- > gdb/compile/compile.c | 31 +++++++++++++++++++++++++++++++ > 1 file changed, 31 insertions(+) > > diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c > index 8481d14..3431d4c 100644 > --- a/gdb/compile/compile.c > +++ b/gdb/compile/compile.c > @@ -633,6 +633,33 @@ struct compile_options > fputs_filtered (message, gdb_stderr); > } > > +/* RAII class used to ignore SIGPIPE in a scope. */ > + > +class scoped_ignore_sigpipe > +{ > +public: > + scoped_ignore_sigpipe () > + { > +#ifdef SIGPIPE > + m_osigpipe = signal (SIGPIPE, SIG_IGN); > +#endif > + } > + > + ~scoped_ignore_sigpipe () > + { > +#ifdef SIGTTOU SIGPIPE? Thanks, Andrew > + signal (SIGPIPE, m_osigpipe); > +#endif > + } > + > + DISABLE_COPY_AND_ASSIGN (scoped_ignore_sigpipe); > + > +private: > +#ifdef SIGPIPE > + sighandler_t m_osigpipe = NULL; > +#endif > +}; > + > /* Process the compilation request. On success it returns the object > and source file names. On an error condition, error () is > called. */ > @@ -755,6 +782,10 @@ struct compile_options > fprintf_unfiltered (gdb_stdlog, "source file produced: %s\n\n", > fnames.source_file ()); > > + /* If we don't do this, then GDB simply exits > + when the compiler dies. */ > + scoped_ignore_sigpipe ignore_sigpipe; > + > /* Call the compiler and start the compilation process. */ > compiler->set_source_file (fnames.source_file ()); > ok = compiler->compile (fnames.object_file (), compile_debug); > -- > 1.9.1 >