From 5a686c5460e9fbb32af5014d0dbf1169ea301ec2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 17 Mar 2017 12:40:02 +0200 Subject: Catch and dump unhandled exceptions in async task functions The problem with relying on noexcept for this is that there is no stack. --- build2/algorithm.cxx | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'build2/algorithm.cxx') 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)) -- cgit v1.1