From patchwork Sat Feb 9 08:24:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 219376 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 8C7502C0084 for ; Sat, 9 Feb 2013 19:25:06 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1361003106; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=N5RrbzxzqChE9It9l1fd BC+RpoM=; b=ZQloDzgn1zsRFrZiN2HTxTk3xjsDHDaJk2byMV9/k3ffF9w8AALb h6fQDyz1mq9Eg7+Z0C1uYcclpZTx84DB8Xb56g9lO//YaQ/Fs/CQoWcPa/9uD4Rz D97MflnrUVIvj4TVwODckW+1ZnjVAcSMZwwLhA0q/uZbcoh9aj4bHH0= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To:MIME-Version:Content-Type:Content-Disposition:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=pURt9NO0JrsX0E5gqPYHT7reVBQYX3ZV0wNE+vTwkQLZ5F5YWBxb7AOfqD45jw Ed2UXuWSlRu0xeRHQaZ1prZBI5Jg0TpeX6ShS2v6YihArATBY5EIIsjPiTmmj4UU oHp0tP5BzzSRCdhoSS3IgktLvqjZbO07Kti84tULr7yv0=; Received: (qmail 2770 invoked by alias); 9 Feb 2013 08:25:00 -0000 Received: (qmail 2755 invoked by uid 22791); 9 Feb 2013 08:24:58 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_UF X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 09 Feb 2013 08:24:50 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r198OnAO008090 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 9 Feb 2013 03:24:50 -0500 Received: from zalov.redhat.com (vpn1-5-153.ams2.redhat.com [10.36.5.153]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r198OlII006235 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 9 Feb 2013 03:24:49 -0500 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.redhat.com (8.14.5/8.14.5) with ESMTP id r198OlTL006067; Sat, 9 Feb 2013 09:24:47 +0100 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r198OlLg006066; Sat, 9 Feb 2013 09:24:47 +0100 Date: Sat, 9 Feb 2013 09:24:46 +0100 From: Jakub Jelinek To: Ian Lance Taylor Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix libiberty/regex on 64-bit hosts (PR other/56245) Message-ID: <20130209082446.GT4385@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi! gengtype when built with -fsanitize=address fails on x86_64-linux. The problem is that realloc often returns addresses which are more than 2GB appart from the old value, and regex.c was using int variable for the pointer difference to adjust the pointers in the realloced buffer. glibc uses a different regex implementation for many years, so this isn't something that should be first fixed in glibc. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2013-02-09 Jakub Jelinek PR other/56245 * regex.c (PTR_INT_TYPE): Define. (EXTEND_BUFFER): Change incr type from int to PTR_INT_TYPE. Jakub --- libiberty/regex.c.jj 2011-05-02 18:39:35.000000000 +0200 +++ libiberty/regex.c 2013-02-08 18:33:18.136802070 +0100 @@ -46,9 +46,11 @@ # if defined STDC_HEADERS && !defined emacs # include +# define PTR_INT_TYPE ptrdiff_t # else /* We need this for `regex.h', and perhaps for the Emacs include files. */ # include +# define PTR_INT_TYPE long # endif # define WIDE_CHAR_SUPPORT (HAVE_WCTYPE_H && HAVE_WCHAR_H && HAVE_BTOWC) @@ -2045,7 +2047,7 @@ static reg_errcode_t byte_compile_range /* How many characters the new buffer can have? */ \ wchar_count = bufp->allocated / sizeof(UCHAR_T); \ if (wchar_count == 0) wchar_count = 1; \ - /* Truncate the buffer to CHAR_T align. */ \ + /* Truncate the buffer to CHAR_T align. */ \ bufp->allocated = wchar_count * sizeof(UCHAR_T); \ RETALLOC (COMPILED_BUFFER_VAR, wchar_count, UCHAR_T); \ bufp->buffer = (char*)COMPILED_BUFFER_VAR; \ @@ -2054,7 +2056,7 @@ static reg_errcode_t byte_compile_range /* If the buffer moved, move all the pointers into it. */ \ if (old_buffer != COMPILED_BUFFER_VAR) \ { \ - int incr = COMPILED_BUFFER_VAR - old_buffer; \ + PTR_INT_TYPE incr = COMPILED_BUFFER_VAR - old_buffer; \ MOVE_BUFFER_POINTER (b); \ MOVE_BUFFER_POINTER (begalt); \ if (fixup_alt_jump) \ @@ -2082,7 +2084,7 @@ static reg_errcode_t byte_compile_range /* If the buffer moved, move all the pointers into it. */ \ if (old_buffer != COMPILED_BUFFER_VAR) \ { \ - int incr = COMPILED_BUFFER_VAR - old_buffer; \ + PTR_INT_TYPE incr = COMPILED_BUFFER_VAR - old_buffer; \ MOVE_BUFFER_POINTER (b); \ MOVE_BUFFER_POINTER (begalt); \ if (fixup_alt_jump) \