From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 935 invoked by alias); 26 Feb 2013 18:27:42 -0000 Received: (qmail 925 invoked by uid 22791); 26 Feb 2013 18:27:42 -0000 X-SWARE-Spam-Status: No, hits=-6.7 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 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; Tue, 26 Feb 2013 18:27:38 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r1QIRbaL016422 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 26 Feb 2013 13:27:37 -0500 Received: from redhat.com (ovpn-116-20.ams2.redhat.com [10.36.116.20]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r1QIRYDn031005 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Tue, 26 Feb 2013 13:27:36 -0500 Date: Tue, 26 Feb 2013 18:27:00 -0000 From: Marek Polacek To: GCC Patches Subject: [PATCH] Fix PR56344 Message-ID: <20130226182733.GG25197@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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: 2013-02/txt/msg01183.txt.bz2 This "fixes" PR56344 by prohibiting passing arguments by value of size >= 2^30 bytes. Probably no sane programmer would want to do that, but it's better to issue an error than to segfault. This would be a good opportunity to use __builtin_expect, but we don't use that much in the codebase... Regtested/bootstrapped on x86_64-linux, ok for trunk? Do we need a testcase for this (compiling it is quite slow)? 2013-02-26 Marek Polacek PR middle-end/56344 * calls.c (expand_call): Disallow passing huge arguments by value. --- gcc/calls.c.mp 2013-02-26 17:04:33.159555349 +0100 +++ gcc/calls.c 2013-02-26 18:50:54.864084545 +0100 @@ -3037,6 +3037,14 @@ expand_call (tree exp, rtx target, int i { rtx before_arg = get_last_insn (); + /* We don't allow passing huge (> 2^30 B) arguments + by value. It would cause an overflow later on. */ + if (adjusted_args_size.constant >= (1 << 30)) + { + error ("passing too large argument on stack"); + continue; + } + if (store_one_arg (&args[i], argblock, flags, adjusted_args_size.var != 0, reg_parm_stack_space) Marek