Memory leak in parallel_reduce

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:

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

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

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

2 帖子 / 0 全新
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项

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.

登陆并发表评论。