From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 114957 invoked by alias); 25 Oct 2018 09:16:15 -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 114665 invoked by uid 89); 25 Oct 2018 09:15:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS,TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy=FORMAT X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 25 Oct 2018 09:15:25 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2D38C341; Thu, 25 Oct 2018 02:15:22 -0700 (PDT) Received: from e120077-lin.cambridge.arm.com (e120077-lin.cambridge.arm.com [10.2.206.194]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E97CA3F627; Thu, 25 Oct 2018 02:15:20 -0700 (PDT) Subject: Re: [PATCH] Fix EQ_ATTR_ALT size calculation (PR bootstrap/87417) To: Ilya Leoshkevich , gcc-patches@gcc.gnu.org Cc: krebbel@linux.ibm.com, rdapp@linux.ibm.com, richard.sandiford@arm.com, ro@CeBiTec.Uni-Bielefeld.DE References: <20180924214916.12356-1-iii@linux.ibm.com> From: "Richard Earnshaw (lists)" Openpgp: preference=signencrypt Message-ID: <0f763816-a3ff-fd14-ca49-c45d4bbe7910@arm.com> Date: Thu, 25 Oct 2018 10:41:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20180924214916.12356-1-iii@linux.ibm.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2018-10/txt/msg01569.txt.bz2 On 24/09/2018 22:49, Ilya Leoshkevich wrote: > Bootstrap and regtest running on s390x-redhat-linux. > > "r264537: Change EQ_ATTR_ALT to support up to 64 alternatives" changed > the format of EQ_ATTR_ALT from ii to ww. This broke the bootstrap on > 32-bit systems, because the formula for rtx_code_size assumed that only > certain codes contain HOST_WIDE_INTs. This did not surface on 64-bit > systems, because rtunion is 8 bytes anyway, but on 32-bit systems it's > only 4 bytes. This resulted in out-of-bounds writes and memory > corruptions in genattrtab. > > gcc/ChangeLog: > > 2018-09-24 Ilya Leoshkevich > > PR bootstrap/87417 > * rtl.c (rtx_code_size): Take into account that EQ_ATTR_ALT > contains HOST_WIDE_INTs when computing its size. > --- > gcc/rtl.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/gcc/rtl.c b/gcc/rtl.c > index f9146afcf2c..ca5c25c422f 100644 > --- a/gcc/rtl.c > +++ b/gcc/rtl.c > @@ -110,8 +110,7 @@ const enum rtx_class rtx_class[NUM_RTX_CODE] = { > > const unsigned char rtx_code_size[NUM_RTX_CODE] = { > #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) \ > - (((ENUM) == CONST_INT || (ENUM) == CONST_DOUBLE \ > - || (ENUM) == CONST_FIXED || (ENUM) == CONST_WIDE_INT) \ > + ((FORMAT)[0] == 'w' \ > ? RTX_HDR_SIZE + (sizeof FORMAT - 1) * sizeof (HOST_WIDE_INT) \ > : (ENUM) == REG \ > ? RTX_HDR_SIZE + sizeof (reg_info) \ > Unfortunately, this leads to a non-functioning stage1 compiler if built with, eg gcc-4.6. What happens is that we end up with a static constructor for rtx_code_size that gets run _after_ a value from the table is read for the static constructor for cselib.c's static pool_allocator value_pool ("value", RTX_CODE_SIZE (VALUE)); and the result is that 0 is passed as the object size. The pool allocator then obviously does weird things. I think the safest thing is to go back to using an explicit list of codes to check; but perhaps we need to get rid of that static constructor for the pool allocator as well. This is all somewhat fragile. R.