Project

General

Profile

Bug #2465

Segmentation fault in mdrun because of file name lenght

Added by Mikhail Serkov about 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
preprocessing (pdb2gmx,grompp)
Target version:
Affected version - extra info:
ftp://ftp.gromacs.org/pub/gromacs/gromacs-2018.tar.gz
Affected version:
Difficulty:
uncategorized
Close

Description

Hello,

I have recently found an issue when two of the tests were failing during the 'make check' with segmentation faults:

25 - GmxPreprocessTests (Child aborted)
32 - MdrunTests (Child aborted)

It was really hard to reproduce, because it was only happening on our build environment ( jenkins + easybuild ). After debugging it appeared that this is happening because of path to the test file is too long. When you use jenkins + easybuild they create a really long folder tree.

During the debug, I found the reason why it is happening:
gromacs-2018/src/gromacs/fileio/warninp.cpp


typedef struct warninp {
    gmx_bool bAllowWarnings;
    int      nwarn_note;
    int      nwarn_warn;
    int      nwarn_error;
    int      maxwarn;
    int      lineno;
    char     filenm[256];
} t_warninp;

There is a declaration of warninp structure, and you may see that finlename size is hardcoded to be 256 characters. If the actual filename is more than 256, done_warning->free_warning->sfree->free causes segmentation fault.

I am not an expert in C++, I can't suggest how to make it more reliable. In my case I just patched the file and set it to 512, which resolved issue. However, it is only a workaround. Some additional handling is needed to check if filename is larger than this limit and throw an error, or set this filename to be dynamic buffer.

Please let me know if any questions.

Best regards,
Mikhail Serkov

Associated revisions

Revision 321dee2d (diff)
Added by Berk Hess about 1 year ago

Change warninp filenm to std::string

This prevent buffer overflows with long filenames.

Fixes #2465

Change-Id: Ifcd264a6b33929f6b369d543c83c16d5378db937

History

#1 Updated by Gerrit Code Review Bot about 1 year ago

Gerrit received a related patchset '1' for Issue #2465.
Uploader: Berk Hess ()
Change-Id: gromacs~release-2018~Ifcd264a6b33929f6b369d543c83c16d5378db937
Gerrit URL: https://gerrit.gromacs.org/7744

#2 Updated by Berk Hess about 1 year ago

  • Category set to preprocessing (pdb2gmx,grompp)
  • Status changed from New to Fix uploaded
  • Assignee set to Berk Hess
  • Target version set to 2018.2

#3 Updated by Berk Hess about 1 year ago

  • Status changed from Fix uploaded to Resolved

#4 Updated by Mark Abraham about 1 year ago

  • Status changed from Resolved to Closed

Will be fixed in 2018.2

Also available in: Atom PDF