public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR56344
@ 2013-02-26 18:27 Marek Polacek
  2013-02-26 23:17 ` Joseph S. Myers
  0 siblings, 1 reply; 12+ messages in thread
From: Marek Polacek @ 2013-02-26 18:27 UTC (permalink / raw)
  To: GCC Patches

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  <polacek@redhat.com>

	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

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-12-02 20:35 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-26 18:27 [PATCH] Fix PR56344 Marek Polacek
2013-02-26 23:17 ` Joseph S. Myers
2013-02-27  9:56   ` Marek Polacek
2013-02-27 11:33     ` Richard Biener
2013-02-27 17:38       ` Joseph S. Myers
2013-03-01  8:41         ` Richard Biener
2013-03-05 16:06           ` Marek Polacek
2013-03-13 12:57             ` Marek Polacek
2013-12-02 15:01               ` Richard Biener
2013-12-02 16:40                 ` Marek Polacek
2013-12-02 19:19                   ` Marek Polacek
2013-12-02 20:35                     ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).