From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id 0D8E138930F2 for ; Mon, 24 May 2021 21:36:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0D8E138930F2 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=segher@kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 14OLZJIR028542; Mon, 24 May 2021 16:35:19 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 14OLZJBd028541; Mon, 24 May 2021 16:35:19 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Mon, 24 May 2021 16:35:19 -0500 From: Segher Boessenkool To: Bernhard Reutner-Fischer Cc: wschmidt@linux.ibm.com, Bill Schmidt via Gcc-patches , dje.gcc@gmail.com Subject: Re: [PATCH 06/57] rs6000: Add helper functions for parsing Message-ID: <20210524213519.GI10366@gate.crashing.org> References: <339c02294ee06570958bc71c772f33736a103fa9.1619537141.git.wschmidt@linux.ibm.com> <20210521185125.GB10366@gate.crashing.org> <784f02c0-f452-c7db-c9a9-94f04cbf1bd2@linux.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, TXREP, T_SPF_HELO_PERMERROR, T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 May 2021 21:36:23 -0000 On Mon, May 24, 2021 at 12:37:30AM +0200, Bernhard Reutner-Fischer wrote: > On 21 May 2021 22:56:09 CEST, Bill Schmidt via Gcc-patches wrote: > >>> + char *buf = (char *) malloc (lastpos - pos + 2); > >>> + memcpy (buf, &linebuf[pos], lastpos - pos + 1); > >>> + buf[lastpos - pos + 1] = '\0'; > You saw the unchecked usage of the malloc return value, did you? Yes, and it is Good. We do not assert on things that will fail on the next statement anyway, in general. Also, this is not part of the compiler, this is a tool used to *build* the compiler, so it is fine to have less user-friendly errors anyway. > We certainly warn about that, I'd hope. Maybe I just don't see what you mean? In general, it is good that we do *not* do superfluous checks normally. There is nothing useful we could say about an out-of-memory situation. If this was in GCC itself we would get a helpful ICE as-is. Since this is in a generator file we can assume whoever debugs this knows how to fire up GDB for it, so it is fine as well. There are thousands of ways a developer can crash the generators by giving bad inputs. An out-of-memory condition is not likely at all, compared to that. Segher