diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-03-17 12:40:02 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-03-17 12:40:02 +0200 |
commit | 5a686c5460e9fbb32af5014d0dbf1169ea301ec2 (patch) | |
tree | aa219f442926ef4879acb2c14f7eead47f9f3d33 /build2/algorithm.cxx | |
parent | de09beabe1448e9c6b401ec9acdd69ee5bf0f0e2 (diff) |
Catch and dump unhandled exceptions in async task functions
The problem with relying on noexcept for this is that there is no stack.
Diffstat (limited to 'build2/algorithm.cxx')
-rw-r--r-- | build2/algorithm.cxx | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/build2/algorithm.cxx b/build2/algorithm.cxx index 4e5ec78..9357632 100644 --- a/build2/algorithm.cxx +++ b/build2/algorithm.cxx @@ -485,6 +485,12 @@ namespace build2 t.state_ = target_state::failed; l.offset = target::offset_applied; } + catch (const std::exception& e) + { + *diag_stream << "unhandled exception: " << e; + assert (false); + abort (); + } return t.state_; } @@ -537,7 +543,9 @@ namespace build2 // if (sched.async (start_count, *task_count, - [a] (target& t, size_t offset, const diag_frame* ds) + [a] (target& t, + size_t offset, + const diag_frame* ds) noexcept { diag_frame df (ds); phase_lock pl (run_phase::match); @@ -779,6 +787,12 @@ namespace build2 { ts = t.state_ = target_state::failed; } + catch (const std::exception& e) + { + *diag_stream << "unhandled exception: " << e; + assert (false); + abort (); + } // Decrement the task count (to count_executed) and wake up any threads // that might be waiting for this target. @@ -864,10 +878,10 @@ namespace build2 // if (sched.async (start_count, *task_count, - [a] (target& t, const diag_frame* ds) + [a] (target& t, const diag_frame* ds) noexcept { diag_frame df (ds); - execute_impl (a, t); // Note: noexcept. + execute_impl (a, t); }, ref (t), diag_frame::stack)) |