Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Darcy_Harrison
Beginner
16 Views

Memory leak in parallel_reduce

Class finish_reduce that has_right_zombie will not call the destructor of the contained body object if the join operation throws.

From parallel_reduce.h:

[cpp]if( has_right_zombie ) {
   // Right child was stolen.
   Body* s = zombie_space.begin();
   my_body->join( *s );
   s->~Body();
}[/cpp]

Clearly s->~Body() will not be called when my_body->join( *s ) throws. I propose:

[cpp]if( has_right_zombie ) {

   // Right child was stolen.
   Body* s = zombie_space.begin();
   try{
      my_body->join( *s );
      s->~Body();
   }catch(...){
      s->~Body();
      throw;
   }
}[/cpp]

0 Kudos
1 Reply
Darcy_Harrison
Beginner
16 Views

Actually, I remembered that I had submitted essentially the same bug but with respect to cancellation. The solution proposed here: http://software.intel.com/en-us/forums/topic/329081 is better.