From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19546 invoked by alias); 9 Oct 2011 19:56:11 -0000 Received: (qmail 19496 invoked by uid 22791); 9 Oct 2011 19:56:10 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (140.186.70.92) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 09 Oct 2011 19:55:56 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RCzTW-0005Jq-Bn for gcc-patches@gcc.gnu.org; Sun, 09 Oct 2011 15:55:55 -0400 Received: from one.firstfloor.org ([213.235.205.2]:35741) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RCzTW-0005Jj-5O for gcc-patches@gcc.gnu.org; Sun, 09 Oct 2011 15:55:54 -0400 Received: by one.firstfloor.org (Postfix, from userid 503) id 72CD422C8074; Sun, 9 Oct 2011 21:55:46 +0200 (CEST) From: Andi Kleen To: gcc-patches@gcc.gnu.org Cc: Andi Kleen Subject: [PATCH 5/5] Add error checking to lto_section_read Date: Sun, 09 Oct 2011 19:56:00 -0000 Message-Id: <1318190141-1220-6-git-send-email-andi@firstfloor.org> In-Reply-To: <1318190141-1220-1-git-send-email-andi@firstfloor.org> References: <1318190141-1220-1-git-send-email-andi@firstfloor.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 213.235.205.2 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/msg00700.txt.bz2 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. gcc/lto/: 2011-10-09 Andi Kleen * lto.c (lto_section_read): Call internal_error on IO or mmap errors. --- gcc/lto/lto.c | 11 +++++++++-- 1 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, { fd = open (file_data->file_name, O_RDONLY|O_BINARY); if (fd == -1) - return NULL; + { + internal_error ("Cannot open %s", file_data->file_name); + return NULL; + } fd_name = xstrdup (file_data->file_name); } @@ -1255,7 +1258,10 @@ lto_read_section_data (struct lto_file_decl_data *file_data, result = (char *) mmap (NULL, computed_len, PROT_READ, MAP_PRIVATE, fd, computed_offset); if (result == MAP_FAILED) - return NULL; + { + internal_error ("Cannot map %s", file_data->file_name); + return NULL; + } return result + diff; #else @@ -1264,6 +1270,7 @@ lto_read_section_data (struct lto_file_decl_data *file_data, || read (fd, result, len) != (ssize_t) len) { free (result); + internal_error ("Cannot read %s", file_data->file_name); result = NULL; } #ifdef __MINGW32__ -- 1.7.5.4