Skip to content

Commit

Permalink
Making error reporting during problems with setting affinity masks mo…
Browse files Browse the repository at this point in the history
…re verbose

- flyby: fix possible double-free of hwloc bitmap
  • Loading branch information
hkaiser committed Oct 8, 2017
1 parent 8ecf819 commit a9079ca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/runtime/threads/policies/hwloc_topology_info.cpp
Expand Up @@ -387,7 +387,10 @@ namespace hpx { namespace threads
boost::scoped_ptr<char> buffer(new char [1024]);

hwloc_bitmap_snprintf(buffer.get(), 1024, cpuset);
hwloc_bitmap_free(cpuset);
if (ec)
{
hwloc_bitmap_free(cpuset);
}

HPX_THROWS_IF(ec, kernel_error
, "hpx::threads::hwloc_topology_info::set_thread_affinity_mask"
Expand All @@ -396,8 +399,7 @@ namespace hpx { namespace threads
HPX_CPU_MASK_PREFIX "%x) for cpuset %s",
mask, buffer.get()));

if (ec)
return;
if (ec) return;
}
}
}
Expand Down
11 changes: 10 additions & 1 deletion src/runtime_impl.cpp
Expand Up @@ -700,9 +700,18 @@ namespace hpx {
// --hpx:bind=none should disable all affinity definitions
if (threads::any(used_processing_units))
{
error_code ec;

this->topology_.set_thread_affinity_mask(
this->topology_.get_service_affinity_mask(
used_processing_units));
used_processing_units), ec);

HPX_THROWS_IF(ec, kernel_error
, "runtime_impl::init_tss_ex"
, hpx::util::format(
"failed to set thread affinity mask ("
HPX_CPU_MASK_PREFIX "%x) for service thread: %s",
used_processing_units, runtime::thread_name_.get()));
}
#endif
}
Expand Down

0 comments on commit a9079ca

Please sign in to comment.