Segmentation fault in mdrun because of file name lenght - Redmine #2465
Archive from user: Mikhail Serkov
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/warnincpp
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_warningfree_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
(from redmine: issue id 2465, created on 2018-03-23 by gmxdefault, closed on 2018-04-03)
- Changesets:
- Revision 321dee2d by Berk Hess on 2018-04-03T08:00:15Z:
Change warninp filenm to std::string
This prevent buffer overflows with long filenames.
Fixes #2465
Change-Id: Ifcd264a6b33929f6b369d543c83c16d5378db937