Skip to content

Commit

Permalink
fix(analytical): Fix Louvain algorithm's move on const message (#3551)
Browse files Browse the repository at this point in the history
Louvain algorithm may core dump as pointer's "double free", I see there
is a std::move() on const message, and it seems that will cause a copy
instead of a move.

Fixes #3550

Co-authored-by: Tao He <[email protected]>
  • Loading branch information
songqing and sighingnow authored Feb 19, 2024
1 parent 7960ce9 commit 268debd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions analytical_engine/apps/pregel/louvain/louvain_app_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class LouvainAppBase
std::vector<std::vector<std::vector<md_t>>> buffer(
thrd_num, std::vector<std::vector<md_t>>(thrd_num));
messages.ParallelProcess<md_t>(
thrd_num, [&thrd_num, &buffer](int tid, md_t const& msg) {
thrd_num, [&thrd_num, &buffer](int tid, md_t& msg) {
buffer[tid][msg.dst_id % thrd_num].emplace_back(std::move(msg));
});
{
Expand All @@ -180,7 +180,7 @@ class LouvainAppBase
threads[tid] = std::thread(
[&frag, &ctx, &thrd_num, &buffer](uint32_t tid) {
for (uint32_t index = 0; index < thrd_num; ++index) {
for (auto const& msg : buffer[index][tid]) {
for (auto& msg : buffer[index][tid]) {
vertex_t v;
frag.InnerVertexGid2Vertex(msg.dst_id, v);
ctx.compute_context().messages_in()[v].emplace_back(
Expand Down

0 comments on commit 268debd

Please sign in to comment.