From patchwork Tue Feb 26 18:27:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 223365 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 B98042C007E for ; Wed, 27 Feb 2013 05:27:48 +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=1362508069; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Date:From:To:Subject:Message-ID: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=VMgayS9f4D7D/a+Eo5RO3naSo8s=; b=AhEld6UhIc3aNSM MinOTAARtLB9j/RD+SCAZsfvxZpZmxgYJCOqRCBxnwfbat/FYCSSKHkwfFAzmXx1 mvbiRcs6chPNKmH6gNtcfwA3PkyOcjPevRMZvmfFKCxfEAXHn8IPOIO8NS7gsLci hhDQJqqcSwBd4ykthmjd7kv+vspQ= 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:Date:From:To:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=rEn0KMkODg41oJLHeRH8m/+mvu+X5ddptipg0sYe19ripVm3YvkkE+lfcsY2Gt HVjit4qL66MZDHMAvWEa4OxOFMsECIHqmgfZ5BSltNjwXvRq4iIggPNbKT7lAm8L dbbzHIiQf+FgX7uVkASPGvNFa5PyTX8VgFdUFjJ2Xlydo=; 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 19:27:33 +0100 From: Marek Polacek To: GCC Patches Subject: [PATCH] Fix PR56344 Message-ID: <20130226182733.GG25197@redhat.com> MIME-Version: 1.0 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-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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. Marek --- 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)