public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Fix overflow in lto-partition.c
@ 2018-02-23 18:19 Jan Hubicka
  0 siblings, 0 replies; only message in thread
From: Jan Hubicka @ 2018-02-23 18:19 UTC (permalink / raw)
  To: gcc-patches

Hi,
this patch fixes fork bomb gcc turns into when you compile firefox with LTO and
profile feedback.  We put partition size to INT_MAX to avoid creation of new
partition but because we compute partition_size * 3 / 2 we end up with negative
bound and producing individual partition for every new symbol.

Bootstrapped/regtested x86_64-linux, commited
We ought to backport this to all release branches.

Honza

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 257938)
+++ ChangeLog	(working copy)
@@ -1,5 +1,9 @@
 2018-02-08  Jan Hubicka  <hubicka@ucw.cz>
 
+	* lto-partition.c (lto_balanced_map): Watch overflow.
+
+2018-02-08  Jan Hubicka  <hubicka@ucw.cz>
+
 	PR ipa/81360
 	* lto.c (unify_scc): Register prevailing trees, not trees to be freed.
 	(read_cgraph_and_symbols): Use
Index: lto-partition.c
===================================================================
--- lto-partition.c	(revision 257938)
+++ lto-partition.c	(working copy)
@@ -757,7 +757,8 @@ lto_balanced_map (int n_lto_partitions,
 	  if (npartitions < n_lto_partitions)
 	    partition_size = total_size / (n_lto_partitions - npartitions);
 	  else
-	    partition_size = INT_MAX;
+	    /* Watch for overflow.  */
+	    partition_size = INT_MAX / 16;
 
 	  if (partition_size < PARAM_VALUE (MIN_PARTITION_SIZE))
 	    partition_size = PARAM_VALUE (MIN_PARTITION_SIZE);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-02-23 18:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-23 18:19 Fix overflow in lto-partition.c Jan Hubicka

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).