grompp segfault when using annealing - Redmine #2871
Archive from user: Daniel Fragiadakis
grompp crashes with a SIGSEGV when reading an input file with the annealing-* commands making annealing unusable.
The culprit is src/gromacs/gmxpreprocess/readir.cpp
In revision fe1788de the way in which these commands are read were
changed introducing an error in reading the floating point values for
anneal-time and anneal-temp into opts.anneal_{time,temp}, they are
being put in memory location 0.
I think the problem is still there in all subsequent versions.
The following patch fixes the problem (I was not able to attach a file to this bug report)
diff --git a/src/gromacs/gmxpreprocess/readir.cpp b/src/gromacs/gmxpreprocess/readir.cpp
index f9b1f27e2..85e0393df 100644
--- a/src/gromacs/gmxpreprocess/readir.cpp
+++ b/src/gromacs/gmxpreprocess/readir.cpp
@@ -3396,8 +3396,18 @@ void do_index(const char* mdparin, const char *ndx,
simulatedAnnealingTemperatures.size(), k);
}
- convertReals(wi, simulatedAnnealingTimes, "anneal-time", ir->opts.anneal_time[i]);
- convertReals(wi, simulatedAnnealingTemperatures, "anneal-temp", ir->opts.anneal_temp[i]);
+ for (i = 0, k = 0; i < nr; i++)
+ {
+ std::vector<std::string> temps(simulatedAnnealingTemperatures.begin(),
+ simulatedAnnealingTemperatures.begin() + ir->opts.anneal_npoints[i]);
+ std::vector<std::string> times(simulatedAnnealingTimes.begin(),
+ simulatedAnnealingTimes.begin() + ir->opts.anneal_npoints[i]);
+
+ convertReals(wi, times, "anneal-time", ir->opts.anneal_time[i]);
+ convertReals(wi, temps, "anneal-temp", ir->opts.anneal_temp[i]);
+ k += ir->opts.anneal_npoints[i];
+ }
+
for (i = 0, k = 0; i < nr; i++)
{
for (j = 0; j < ir->opts.anneal_npoints[i]; j++)
(from redmine: issue id 2871, created on 2019-02-26 by gmxdefault, closed on 2019-04-05)
- Changesets:
- Revision 2404693f by Paul Bauer on 2019-04-02T13:18:38Z:
Fix simulated annealing and add test
Refs #2871
Change-Id: Ibde5226a664d3d4d5558477fdf9b81e1219a5295
- Revision 9453ea8c by Paul Bauer on 2019-04-04T15:04:43Z:
Fix segmentation fault with simulated annealing
Fix contributed by Daniel Fragiadakis.
Fixes #2871
Change-Id: I237d49f9996eb2ae869d59e4c39a6c2d33c9ece7