From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1166 invoked by alias); 24 Jan 2014 23:02:46 -0000 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 Received: (qmail 1155 invoked by uid 89); 24 Jan 2014 23:02:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL,BAYES_00,KAM_MXURI,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mail.ud10.udmedia.de Received: from ud10.udmedia.de (HELO mail.ud10.udmedia.de) (194.117.254.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 24 Jan 2014 23:02:43 +0000 Received: (qmail 1477 invoked from network); 25 Jan 2014 00:02:40 +0100 Received: from unknown (HELO x4) (ud10?360p3@91.64.96.185) by mail.ud10.udmedia.de with ESMTPSA (DHE-RSA-AES256-SHA encrypted, authenticated); 25 Jan 2014 00:02:40 +0100 Date: Fri, 24 Jan 2014 23:02:00 -0000 From: Markus Trippelsdorf To: Dodji Seketeli Cc: Jakub Jelinek , Bernd Edlinger , GCC Patches , Tom Tromey , Manuel =?iso-8859-1?B?TPNwZXotSWLh8WV6?= Subject: Re: [PATCH] preprocessor/58580 - preprocessor goes OOM with warning for zero literals Message-ID: <20140124230239.GH396@x4> References: <878uwuap4f.fsf@redhat.com> <878uwt63e2.fsf@redhat.com> <20131113081610.GH27813@tucnak.zalov.cz> <87zjp7t73c.fsf@redhat.com> <87vbxcig8t.fsf@redhat.com> <20140124150532.GB396@x4> <87iot9qtff.fsf@redhat.com> <20140124154419.GQ892@tucnak.redhat.com> <878uu5qs3q.fsf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <878uu5qs3q.fsf@redhat.com> X-SW-Source: 2014-01/txt/msg01637.txt.bz2 On 2014.01.24 at 17:09 +0100, Dodji Seketeli wrote: > Jakub Jelinek writes: > > > On Fri, Jan 24, 2014 at 04:40:52PM +0100, Dodji Seketeli wrote: > >> > The patch causes http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59935 . > >> > The follow-up patch (fp == NULL check) doesn't help. > >> > >> I am looking into that, sorry for the inconvenience. > > > > I'd say we want something like following. Note that while the c == NULL > > bailout would be usually sufficient, if you'll do: > > echo foobar > '' > > it would still crash. Line 0 is used only for the special locations > > (command line, built-in macros) and there is no file associated with it > > anyway. > > > > --- gcc/input.c.jj 2014-01-24 16:32:34.000000000 +0100 > > +++ gcc/input.c 2014-01-24 16:41:42.012671452 +0100 > > @@ -698,7 +698,13 @@ location_get_source_line (expanded_locat > > static char *buffer; > > static ssize_t len; > > > > - fcache * c = lookup_or_add_file_to_cache_tab (xloc.file); > > + if (xloc.line == 0) > > + return NULL; > > + > > + fcache *c = lookup_or_add_file_to_cache_tab (xloc.file); > > + if (c == NULL) > > + return NULL; > > + > > bool read = read_line_num (c, xloc.line, &buffer, &len); > > > > if (read && line_len) > > Indeed. > > Though, I am testing the patch below that makes read_line_num gracefully > handle empty caches or zero locations. The rest of the code should just > work with that as is. > > * input.c (read_line_num): Gracefully handle non-file locations or > empty caches. Unfortunately this doesn't fix yet another issue: markus@x4 /tmp % cat foo.c #line 4636 "configure" #include int main() { return 0; } markus@x4 /tmp % gcc foo.c configure:4636:26: fatal error: xxxxxxxxxxxx.h: No such file or directory gcc: internal compiler error: Segmentation fault (program cc1) 0x40cc8e execute ../../gcc/gcc/gcc.c:2841 0x40cf09 do_spec_1 ../../gcc/gcc/gcc.c:4641 0x40fc91 process_brace_body ../../gcc/gcc/gcc.c:5924 0x40fc91 handle_braces ../../gcc/gcc/gcc.c:5838 0x40d692 do_spec_1 ../../gcc/gcc/gcc.c:5295 0x40fc91 process_brace_body ../../gcc/gcc/gcc.c:5924 0x40fc91 handle_braces ../../gcc/gcc/gcc.c:5838 0x40d692 do_spec_1 ../../gcc/gcc/gcc.c:5295 0x40d28e do_spec_1 ../../gcc/gcc/gcc.c:5410 0x40fc91 process_brace_body ../../gcc/gcc/gcc.c:5924 0x40fc91 handle_braces ../../gcc/gcc/gcc.c:5838 0x40d692 do_spec_1 ../../gcc/gcc/gcc.c:5295 0x40fc91 process_brace_body ../../gcc/gcc/gcc.c:5924 0x40fc91 handle_braces ../../gcc/gcc/gcc.c:5838 0x40d692 do_spec_1 ../../gcc/gcc/gcc.c:5295 0x40fc91 process_brace_body ../../gcc/gcc/gcc.c:5924 0x40fc91 handle_braces ../../gcc/gcc/gcc.c:5838 0x40d692 do_spec_1 ../../gcc/gcc/gcc.c:5295 0x40fc91 process_brace_body ../../gcc/gcc/gcc.c:5924 0x40fc91 handle_braces ../../gcc/gcc/gcc.c:5838 Please submit a full bug report, with preprocessed source if appropriate. -- Markus