From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5343 invoked by alias); 10 Oct 2011 10:17:10 -0000 Received: (qmail 5335 invoked by uid 22791); 10 Oct 2011 10:17:09 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-gx0-f175.google.com (HELO mail-gx0-f175.google.com) (209.85.161.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 10 Oct 2011 10:16:55 +0000 Received: by ggnq1 with SMTP id q1so5124541ggn.20 for ; Mon, 10 Oct 2011 03:16:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.150.210.3 with SMTP id i3mr5470940ybg.45.1318241814795; Mon, 10 Oct 2011 03:16:54 -0700 (PDT) Received: by 10.151.9.9 with HTTP; Mon, 10 Oct 2011 03:16:54 -0700 (PDT) In-Reply-To: <1318190141-1220-6-git-send-email-andi@firstfloor.org> References: <1318190141-1220-1-git-send-email-andi@firstfloor.org> <1318190141-1220-6-git-send-email-andi@firstfloor.org> Date: Mon, 10 Oct 2011 10:25:00 -0000 Message-ID: Subject: Re: [PATCH 5/5] Add error checking to lto_section_read From: Richard Guenther To: Andi Kleen Cc: gcc-patches@gcc.gnu.org, Andi Kleen Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-10/txt/msg00725.txt.bz2 On Sun, Oct 9, 2011 at 9:55 PM, Andi Kleen wrote: > From: Andi Kleen > > Various callers of lto_section_read segfault on a NULL return > when the mmap fails. Add some internal_errors to give a better > message to the user. Hm, shouldn't these be fatal_error () then? Ok with that change. Thanks, Richard. > gcc/lto/: > > 2011-10-09 =A0 Andi Kleen > > =A0 =A0 =A0 =A0* lto.c (lto_section_read): Call internal_error on IO or m= map errors. > --- > =A0gcc/lto/lto.c | =A0 11 +++++++++-- > =A01 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c > index a77eeb4..dc16db4 100644 > --- a/gcc/lto/lto.c > +++ b/gcc/lto/lto.c > @@ -1237,7 +1237,10 @@ lto_read_section_data (struct lto_file_decl_data *= file_data, > =A0 =A0 { > =A0 =A0 =A0 fd =3D open (file_data->file_name, O_RDONLY|O_BINARY); > =A0 =A0 =A0 if (fd =3D=3D -1) > - =A0 =A0 =A0 return NULL; > + =A0 =A0 =A0 =A0{ > + =A0 =A0 =A0 =A0 internal_error ("Cannot open %s", file_data->file_name); > + =A0 =A0 =A0 =A0 return NULL; > + =A0 =A0 =A0 =A0} > =A0 =A0 =A0 fd_name =3D xstrdup (file_data->file_name); > =A0 =A0 } > > @@ -1255,7 +1258,10 @@ lto_read_section_data (struct lto_file_decl_data *= file_data, > =A0 result =3D (char *) mmap (NULL, computed_len, PROT_READ, MAP_PRIVATE, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fd, computed_offset); > =A0 if (result =3D=3D MAP_FAILED) > - =A0 =A0return NULL; > + =A0 =A0{ > + =A0 =A0 =A0internal_error ("Cannot map %s", file_data->file_name); > + =A0 =A0 =A0return NULL; > + =A0 =A0} > > =A0 return result + diff; > =A0#else > @@ -1264,6 +1270,7 @@ lto_read_section_data (struct lto_file_decl_data *f= ile_data, > =A0 =A0 =A0 || read (fd, result, len) !=3D (ssize_t) len) > =A0 =A0 { > =A0 =A0 =A0 free (result); > + =A0 =A0 =A0internal_error ("Cannot read %s", file_data->file_name); > =A0 =A0 =A0 result =3D NULL; > =A0 =A0 } > =A0#ifdef __MINGW32__ > -- > 1.7.5.4 > >