Hi folks.

Torvald has a testcase from the STAMP benchmark that is showing a memory corruption error after my fix to publication safety problems.

The problem is we're allocating a chunk of worklist memory of size n_basic_blocks which changes with tail merge optimization and such. We end up with a smaller n_basic_blocks than some of the BB's left in the region. I believe what we want is last_basic_block.

This fixes the memory corruption bug. I couldn't minimize a sensible testcase.

        * trans-mem.c (tm_region_init): Use last_basic_block.

Index: trans-mem.c
--- trans-mem.c (revision 184935)
+++ trans-mem.c (working copy)
@@ -1868,7 +1868,7 @@ tm_region_init (struct tm_region *region
      using bb->aux.  */
   region_worklist =
     (struct tm_region **) xcalloc (sizeof (struct tm_region *),
-                                 n_basic_blocks + NUM_FIXED_BLOCKS + 2);
+                                 last_basic_block + NUM_FIXED_BLOCKS);
   VEC_safe_push (basic_block, heap, queue, bb);
   region_worklist[bb->index] = region;

Reply via email to