From: Andrey Alekseenko Date: Mon, 18 Oct 2021 13:16:49 +0000 (+0000) Subject: Fix UB when generating local indices for constraints X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?p=alexxy%2Fgromacs.git;a=commitdiff_plain;h=750108f507ae426359e41a81f10104df330829cf Fix UB when generating local indices for constraints --- diff --git a/src/gromacs/essentialdynamics/edsam.cpp b/src/gromacs/essentialdynamics/edsam.cpp index ad5e7d9295..48dafd3d0a 100644 --- a/src/gromacs/essentialdynamics/edsam.cpp +++ b/src/gromacs/essentialdynamics/edsam.cpp @@ -3062,14 +3062,15 @@ std::unique_ptr init_edsam(const gmx::MDLogger& m } /* end of MASTER only section */ - if (PAR(cr)) + if (haveDDAtomOrdering(*cr)) { - /* Broadcast the essential dynamics / flooding data to all nodes */ + /* Broadcast the essential dynamics / flooding data to all nodes. + * In a single-rank case, only the necessary memory allocation is done. */ broadcast_ed_data(cr, ed); } else { - /* In the single-CPU case, point the local atom numbers pointers to the global + /* In the non-DD case, point the local atom numbers pointers to the global * one, so that we can use the same notation in serial and parallel case: */ /* Loop over all ED data sets (usually only one, though) */ for (auto edi = ed->edpar.begin(); edi != ed->edpar.end(); ++edi) diff --git a/src/gromacs/mdlib/groupcoord.cpp b/src/gromacs/mdlib/groupcoord.cpp index ac84c96273..adbf364c89 100644 --- a/src/gromacs/mdlib/groupcoord.cpp +++ b/src/gromacs/mdlib/groupcoord.cpp @@ -62,6 +62,7 @@ void dd_make_local_group_indices(const gmx_ga2la_t* ga2la, int coll_ind[]) /* OUT (opt): Where is this position found in the collective array? */ { GMX_ASSERT(ga2la, "We need a valid ga2la object"); + GMX_RELEASE_ASSERT(anrs != *anrs_loc, "Can not update indices in-place"); /* Loop over all the atom indices of the group to check * which ones are on the local node */