From: Berk Hess Date: Wed, 12 Dec 2018 09:23:46 +0000 (+0100) Subject: Fixed nullptr derefence in LINCS error X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=b23d123479a36a28a734b75266e40d83ad99056a;p=alexxy%2Fgromacs.git Fixed nullptr derefence in LINCS error Somehow a dereferenced nullptr could be passed as a reference to gmx_multisim_t to the Constraint factory function. Changed the reference in the Constraint object to a pointer. Fixed #2803 Change-Id: I4806069973067d27078a1324d18a406c7b3e227d --- diff --git a/src/gromacs/mdlib/constr.cpp b/src/gromacs/mdlib/constr.cpp index f1ec807362..0a20f8baaf 100644 --- a/src/gromacs/mdlib/constr.cpp +++ b/src/gromacs/mdlib/constr.cpp @@ -104,7 +104,7 @@ class Constraints::Impl FILE *log_p, const t_mdatoms &md_p, const t_commrec *cr_p, - const gmx_multisim_t &ms, + const gmx_multisim_t *ms, t_nrnb *nrnb, gmx_wallcycle *wcycle_p, bool pbcHandlingRequired, @@ -171,7 +171,7 @@ class Constraints::Impl //! Communication support. const t_commrec *cr = nullptr; //! Multi-sim support. - const gmx_multisim_t &ms; + const gmx_multisim_t *ms = nullptr; /*!\brief Input options. * * \todo Replace with IMdpOptions */ @@ -958,7 +958,7 @@ Constraints::Constraints(const gmx_mtop_t &mtop, FILE *log, const t_mdatoms &md, const t_commrec *cr, - const gmx_multisim_t &ms, + const gmx_multisim_t *ms, t_nrnb *nrnb, gmx_wallcycle *wcycle, bool pbcHandlingRequired, @@ -983,7 +983,7 @@ Constraints::Impl::Impl(const gmx_mtop_t &mtop_p, FILE *log_p, const t_mdatoms &md_p, const t_commrec *cr_p, - const gmx_multisim_t &ms_p, + const gmx_multisim_t *ms_p, t_nrnb *nrnb_p, gmx_wallcycle *wcycle_p, bool pbcHandlingRequired, diff --git a/src/gromacs/mdlib/constr.h b/src/gromacs/mdlib/constr.h index 804f51bbdf..ecb713ce14 100644 --- a/src/gromacs/mdlib/constr.h +++ b/src/gromacs/mdlib/constr.h @@ -103,7 +103,7 @@ class Constraints FILE *log, const t_mdatoms &md, const t_commrec *cr, - const gmx_multisim_t &ms, + const gmx_multisim_t *ms, t_nrnb *nrnb, gmx_wallcycle *wcycle, bool pbcHandlingRequired, diff --git a/src/gromacs/mdlib/lincs.cpp b/src/gromacs/mdlib/lincs.cpp index 543c1848dd..e6e6a33b66 100644 --- a/src/gromacs/mdlib/lincs.cpp +++ b/src/gromacs/mdlib/lincs.cpp @@ -2414,7 +2414,7 @@ bool constrain_lincs(bool computeRmsd, int64_t step, Lincs *lincsd, const t_mdatoms &md, const t_commrec *cr, - const gmx_multisim_t &ms, + const gmx_multisim_t *ms, const rvec *x, rvec *xprime, rvec *min_proj, matrix box, t_pbc *pbc, real lambda, real *dvdlambda, @@ -2560,9 +2560,9 @@ bool constrain_lincs(bool computeRmsd, { cconerr(lincsd, xprime, pbc, &ncons_loc, &p_ssd, &p_max, &p_imax); - if (isMultiSim(&ms)) + if (isMultiSim(ms)) { - sprintf(buf3, " in simulation %d", ms.sim); + sprintf(buf3, " in simulation %d", ms->sim); } else { diff --git a/src/gromacs/mdlib/lincs.h b/src/gromacs/mdlib/lincs.h index fe172a4746..c04741e45f 100644 --- a/src/gromacs/mdlib/lincs.h +++ b/src/gromacs/mdlib/lincs.h @@ -97,7 +97,7 @@ constrain_lincs(bool computeRmsd, int64_t step, Lincs *lincsd, const t_mdatoms &md, const t_commrec *cr, - const gmx_multisim_t &ms, + const gmx_multisim_t *ms, const rvec *x, rvec *xprime, rvec *min_proj, matrix box, t_pbc *pbc, real lambda, real *dvdlambda, diff --git a/src/gromacs/mdrun/runner.cpp b/src/gromacs/mdrun/runner.cpp index c507f477b0..060c83f33a 100644 --- a/src/gromacs/mdrun/runner.cpp +++ b/src/gromacs/mdrun/runner.cpp @@ -1390,7 +1390,7 @@ int Mdrunner::mdrunner() || observablesHistory.edsamHistory); auto constr = makeConstraints(mtop, *inputrec, doEssentialDynamics, fplog, *mdAtoms->mdatoms(), - cr, *ms, nrnb, wcycle, fr->bMolPBC); + cr, ms, nrnb, wcycle, fr->bMolPBC); if (DOMAINDECOMP(cr)) {