Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making sure remotely thrown (non-hpx) exceptions are properly marshaled back to invocation site #4887

Merged
merged 1 commit into from
Aug 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/util/serialize_exception.cpp
Expand Up @@ -117,6 +117,10 @@ namespace hpx { namespace runtime_local { namespace detail {
if (auxinfo_)
throw_auxinfo_ = *auxinfo_;
}
catch (...)
{
// do nothing
}

// figure out concrete underlying exception type
try
Expand Down Expand Up @@ -216,7 +220,7 @@ namespace hpx { namespace runtime_local { namespace detail {
else if (hpx::util::boost_system_error == type)
{
// clang-format off
ar & err_value& err_message;
ar & err_value & err_message;
// clang-format on
}
}
Expand Down Expand Up @@ -262,7 +266,7 @@ namespace hpx { namespace runtime_local { namespace detail {
else if (hpx::util::boost_system_error == type)
{
// clang-format off
ar & err_value& err_message;
ar & err_value & err_message;
// clang-format on
}

Expand Down
5 changes: 4 additions & 1 deletion tests/regressions/util/CMakeLists.txt
Expand Up @@ -8,9 +8,12 @@
set(tests protect_with_nullary_pfo set_config_entry_deadlock use_all_cores_2262)

if(HPX_WITH_DISTRIBUTED_RUNTIME)
set(tests ${tests} configuration_1572 iarchive_1237 serialize_buffer_1069)
set(tests ${tests} configuration_1572 iarchive_1237 serialize_buffer_1069
serialize_exception_4886
)
set(iarchive_1237_FLAGS DEPENDENCIES iostreams_component)
set(serialize_buffer_1069_FLAGS DEPENDENCIES iostreams_component)
set(serialize_exception_4886_1001_PARAMETERS LOCALITIES 2)
endif()

if(HPX_WITH_NETWORKING)
Expand Down
46 changes: 46 additions & 0 deletions tests/regressions/util/serialize_exception_4886.cpp
@@ -0,0 +1,46 @@
// Copyright (c) 2020 Nikunj Gupta
//
// SPDX-License-Identifier: BSL-1.0
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <hpx/hpx.hpp>
#include <hpx/hpx_main.hpp>
#include <hpx/modules/testing.hpp>

#include <exception>

void thrower()
{
throw std::exception();
}
HPX_PLAIN_ACTION(thrower, thrower_action);

int main()
{
hpx::id_type to_call = hpx::find_here();

std::vector<hpx::id_type> locales = hpx::find_all_localities();
for (auto const& id : locales)
{
if (id != to_call)
{
to_call = id;
break;
}
}

thrower_action ac;
hpx::future<void> f = hpx::async(ac, to_call);

bool caught_exception = false;
hpx::future<void> g =
f.then(hpx::launch::sync, [&caught_exception](hpx::future<void>&& f) {
caught_exception = f.has_exception();
});

g.get();
HPX_TEST(caught_exception);

return hpx::util::report_errors();
}