From a291d146c1c730510ca3e6b4ecae6c4694dad2cd Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 22 Mar 2017 19:20:55 +0200 Subject: Diagnose unhandled exceptions in testscript builtins thread thunk --- build2/test/script/builtin.cxx | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'build2') diff --git a/build2/test/script/builtin.cxx b/build2/test/script/builtin.cxx index 6f63551..3305c3a 100644 --- a/build2/test/script/builtin.cxx +++ b/build2/test/script/builtin.cxx @@ -1362,13 +1362,22 @@ namespace build2 scope& sp, const strings& args, auto_fd in, auto_fd out, auto_fd err, - promise p) + promise p) noexcept { - // The use of set_value_at_thread_exit() would be more appropriate but - // the function is not supported by old versions of g++ (e.g., not in - // 4.9). There could also be overhead associated with it. - // - p.set_value (fn (sp, args, move (in), move (out), move (err))); + try + { + // The use of set_value_at_thread_exit() would be more appropriate + // but the function is not supported by old versions of g++ (e.g., + // not in 4.9). There could also be overhead associated with it. + // + p.set_value (fn (sp, args, move (in), move (out), move (err))); + } + catch (const std::exception& e) + { + *diag_stream << "unhandled exception: " << e; + assert (false); + abort (); + } } // Run builtin implementation asynchronously. -- cgit v1.1