Project

General

Profile

Bug #1806

"ref-t" for temperature coupling not validated

Added by James Barnett over 4 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Low
Assignee:
-
Category:
-
Target version:
-
Affected version - extra info:
Affected version:
Difficulty:
uncategorized
Close

Description

Invalid values (e.g., letters, symbols, etc.) can be set as "ref-t" in an mdp file. When done so, GROMACS silently sets ref-t to 0.

mdout.mdp (11.5 KB) mdout.mdp James Barnett, 08/13/2015 06:55 PM
test.tpr (36 KB) test.tpr James Barnett, 08/13/2015 06:55 PM

Associated revisions

Revision fc8a2e55 (diff)
Added by James Barnett over 4 years ago

Validate strings converted to numbers in mdp files

Check that strings converted by strtod() and strtol() only contain
numbers separated by spaces.

Resolves #1806.

Change-Id: Ia369c1f1ee809f6fbb9f43c31a1cb03cfc60fbce

History

#1 Updated by James Barnett over 4 years ago

#2 Updated by Justin Lemkul over 4 years ago

  • Priority changed from Normal to Low

Unfortunately this is the expected behavior of the strtod() function, and is also what e.g. atof() does - returns zero if it can't convert what is passed to it. We can't necessarily guard against a zero value, because that could be desired (albeit odd) for ref_t. Maybe a warning note? Not really a bug, just an unintended consequence of junk input.

#3 Updated by James Barnett over 4 years ago

Everything else seems to be validated. I'm working on a fix.

#4 Updated by Gerrit Code Review Bot over 4 years ago

Gerrit received a related patchset '1' for Issue #1806.
Uploader: James "Wes" Barnett ()
Change-Id: Ia369c1f1ee809f6fbb9f43c31a1cb03cfc60fbce
Gerrit URL: https://gerrit.gromacs.org/4992

#5 Updated by Teemu Murtola over 4 years ago

Justin Lemkul wrote:

Unfortunately this is the expected behavior of the strtod() function, and is also what e.g. atof() does - returns zero if it can't convert what is passed to it.

No, this is just a consequence of not bothering to use the facilities that strtod() provides for input checking. And this is not the only field that has the same issue, either; searching for use of strtod() in readir.c(pp) shows several others as well.

#6 Updated by Erik Lindahl almost 4 years ago

  • Status changed from New to Resolved

While this particular case is resolved, we should gradually move to a new (JSON?) format with proper checking of all values.

#7 Updated by Erik Lindahl almost 4 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF