From: Wolfgang Bangerth Date: Sun, 2 Jun 2013 18:13:30 +0000 (+0000) Subject: More gracefully handle the case that an exception is thrown on a task created by... X-Git-Tag: v8.0.0~333 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d9b6ea4995c35fb2ded0ed22e45e78379cbbf3e;p=dealii.git More gracefully handle the case that an exception is thrown on a task created by Threads::new_task. Unfortunately, I could not come up with a way to write a test for this case :-( git-svn-id: https://svn.dealii.org/trunk@29727 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 481f12e462..fa981c6d96 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -130,8 +130,15 @@ this function.

Specific improvements

    +
  1. Fixed: If an exception was generated on a task created by +Threads::new_task, the program would terminate with a segmentation +fault, leaving little trace of what had happened. This is now handled +more gracefully. +
    +(Wolfgang Bangerth, 2013/06/02) +
  2. -
  3. Changed: subdomainids can now only be queried/set on active cells. +
  4. Changed: subdomain ids can now only be queried/set on active cells. Consequently, is_artificial(), is_ghost(), and is_locally_owned() is now restricted to active cells.
    diff --git a/deal.II/include/deal.II/base/thread_management.h b/deal.II/include/deal.II/base/thread_management.h index 316ba303b3..099f03927b 100644 --- a/deal.II/include/deal.II/base/thread_management.h +++ b/deal.II/include/deal.II/base/thread_management.h @@ -4059,7 +4059,18 @@ namespace Threads // call the function object // and put the return value // into the proper place - call (task_descriptor.function, task_descriptor.ret_val); + try + { + call (task_descriptor.function, task_descriptor.ret_val); + } + catch (const std::exception &exc) + { + internal::handle_std_exception (exc); + } + catch (...) + { + internal::handle_unknown_exception (); + } return 0; } @@ -4234,7 +4245,7 @@ namespace Threads // the TBB book on pages // 230/231 ("Start a large task // in parallel with the main - // program) + // program") task = new (tbb::task::allocate_root()) tbb::empty_task; task->set_ref_count (2); @@ -4349,6 +4360,7 @@ namespace Threads { call (function, ret_val); } + /** * Wait for the task to * return. Since we are in