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  <hubi...@ucw.cz>
 
+       * lto-partition.c (lto_balanced_map): Watch overflow.
+
+2018-02-08  Jan Hubicka  <hubi...@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);

Reply via email to