This thread is locked.Only browsing is available.
Top Page > Browsing
Long directory path for argument DATA.PATH in the input file causes OpenMX to segfault
Date: 2011/08/03 21:10
Name: Renato Miceli
References: http://www.ichec.ie/

Hi,

I've identified that having a directory path longer than 99 characters for argument DATA.PATH (in the input file) causes a segmentation fault to happen in OpenMX. This is due to the String that holds this path be statically allocated to length 100 (String content + the null character terminator '\0'). In openmx_common.h, it can be seen the that...

---------------
char DFT_DATA_PATH[YOUSO10];
---------------

where YOUSO10 is, as defined in the same header...

---------------
#define YOUSO10 100 /* length of a file name */
---------------

Therefore, directory paths longer than 99 characters will overrun the String boundary and overlap the next memory spaces, causing memory errors. This is known as String overflow.

For an execution where DATA.PATH is set to "an/immensely/hugely/enormously/gigantically/very/long/directory/path/set/to/data/path/argument/in/input/file", the backtrace is the following:

---------------
#0 0x0000000000408626 in fnjoint2 (
name1=0x7fff69fb6a30 "ath/argument/in/input/file/VPS/Sn_11an/immensely/hugely/enormously/gigantically/very/long/directory/path/set/to/data/path/argument/in/input/file/VPS/Sn_11an/immensely/hugely/enormously/gigantically/ve"..., name2=0x9d1e880 "Sn_11",
name3=0x7fff69fb6968 "an/immensely/hugely/enormously/gigantically/very/long/directory/path/set/to/data/path/argument/in/input/file/VPS/Sn_11an/immensely/hugely/enormously/gigantically/very/long/directory/path/set/to/data/p"...,
name4=0x7fff69fb6904 "an/immensely/hugely/enormously/gigantically/very/long/directory/path/set/to/data/path/argument/in/inan/immensely/hugely/enormously/gigantically/very/long/directory/path/set/to/data/path/argument/in/in"...) at openmx_common.c:407
#1 0x0000000000447b9a in ReadPara_DFT () at SetPara_DFT.c:256
---------------

All MPI processes died, raising signal 11 within 8 seconds walltime.

In order to avoid String overflow, I propose a simple solution to this bug: adopt dynamic Strings rather than statically defined ones, since dynamic Strings can handle barely any length (the limit is the amount of space free in the heap). In the meantime, I suggest that the current limit of 99 characters to the directory path be added to the manual, namely on this section:
http://www.openmx-square.org/openmx_man3.5/node17.html

This bug is very straightforward, so all the information contained here should be enough. In case you need anything else, please let me know.

Finally, please bear in mind that this bug may affect the other Strings read from the input file, as, if I recall correctly, they are statically defined as well.

Thank you in advance for your collaboration.

Kindest regards,
Renato Miceli
メンテ
Page: [1]

Re: Long directory path for argument DATA.PATH in the input file causes OpenMX to segfault ( No.1 )
Date: 2011/08/05 01:47
Name: T.Ozaki

Dear Renato,

Thank you very much for your continuous effort to improve OpenMX.
We have also been aware of that problem, while it has not been regarded
as urgent issue. We will fix the problem in the next release.

Best regards,

TO
メンテ

Page: [1]