Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions gloo/test/base_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <gtest/gtest.h>

#include <atomic>
#include <exception>
#include <functional>
#include <stdexcept>
Expand Down Expand Up @@ -112,18 +113,25 @@ class BaseTest : public ::testing::Test {
device_creator,
std::function<void(std::shared_ptr<Context>)> fn,
int base = 2) {
// Track whether workers found the transport unavailable so we can call
// GTEST_SKIP() from the main thread after joining. GTEST_SKIP() is not
// thread-safe and must not be called from worker threads — doing so
// causes a data race on GTest internals that can manifest as
// "terminate called recursively" (SIGABRT / exit code 134).
std::atomic<bool> transportUnavailable{false};

Barrier barrier(size);
auto store = std::make_shared<::gloo::rendezvous::HashStore>();

spawnThreads(size, [&](int rank) {
auto context =
std::make_shared<::gloo::rendezvous::Context>(rank, size, base);

// Create device per thread to avoid collisions then they are using the
// Create device per thread to avoid collisions when they are using the
// socket address.
auto device = device_creator(transport);
if (!device) {
GTEST_SKIP() << "Skipping test: transport not available";
transportUnavailable.store(true);
return;
}
context->connectFullMesh(store, device);
Expand All @@ -150,6 +158,10 @@ class BaseTest : public ::testing::Test {
context->closeConnections();
}
});

if (transportUnavailable.load()) {
GTEST_SKIP() << "Skipping test: transport not available";
}
}

void spawn(
Expand Down
14 changes: 11 additions & 3 deletions gloo/transport/ibverbs/device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,22 @@ Device::~Device() {
done_ = true;
loop_->join();

// Log errors instead of throwing — destructors are implicitly noexcept
// in C++11+, so a throw here calls std::terminate().
rv = ibv_destroy_comp_channel(comp_channel_);
GLOO_ENFORCE_EQ(rv, 0, strerror(errno));
if (rv != 0) {
GLOO_ERROR("ibv_destroy_comp_channel: ", strerror(errno));
}

rv = ibv_dealloc_pd(pd_);
GLOO_ENFORCE_EQ(rv, 0, strerror(errno));
if (rv != 0) {
GLOO_ERROR("ibv_dealloc_pd: ", strerror(errno));
}

rv = ibv_close_device(context_);
GLOO_ENFORCE_EQ(rv, 0, strerror(errno));
if (rv != 0) {
GLOO_ERROR("ibv_close_device: ", strerror(errno));
}
}

std::string Device::str() const {
Expand Down
Loading