[gmx-users] pdb2gmx segmentation fault

Ragothaman Yennamalli ragothaman at gmail.com
Fri Apr 22 19:05:21 CEST 2011


Hi all,
With the help of my colleague Nathan Weeks I am able to run pdb2gmx and all
other commands successfully . Here are his responses which he wanted me to
share with you in case someone is trying to install Gromacs in a similar
system.

We set CFLAGS that way due to the following message when running configure:

########################################
checking whether gcc-4.3.2 accepts -native -fast -xO5 -fsimple=2
-fnonstd -dalign -O3 -fomit-frame-pointer -finline-functions -Wall
-Wno-unused -msse2 -funroll-
all-loops -std=gnu99... no
*******************************************************************
* Sorry, these optimization settings don't seem to work for       *
* your C compiler. Use make CFLAGS=..., or edit the top Makefile. *
*******************************************************************
########################################

The "-native -fast -xO5 -fsimple=2 -fnonstd -dalign" options that get
generated are for Solaris Studio, but we're using GCC.  Also,
"-D_POSIX_PTHREAD_SEMANTICS" is required on Solaris to make use of the POSIX
versions of reentrant functions like ctime_r() and readdir_r() (if the
standard _POSIX_C_SOURCE or _XOPEN_SOURCE feature test macros
are set, _POSIX_PTHREAD_SEMANTICS will automatically be set as well).

The memory fault that occurs when running pdb2gmx is due to a non-portable
use
of readdir_r() in futil.c; specifically, on Linux, the dirent structure
has a "char d_name[256]" member, and on Solaris, it is "char d_name[1]", and
the user is required to allocate memory to store its contents. The Linux
readdir(3) man page gives an example of how to do this portably:

http://www.kernel.org/doc/man-pages/online/pages/man3/readdir.3.html

I applied this method to futil.c, and it fixed the memory fault problem:

########################################
--- src/gmxlib/futil.c.orig     2011-03-15 07:44:30.000000000 -0500
+++ src/gmxlib/futil.c  2011-04-20 13:04:58.388912208 -0500
@@ -37,6 +37,7 @@
 #include <config.h>
 #endif

+#include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -595,22 +596,28 @@

 #ifdef HAVE_DIRENT_H

-    struct dirent           tmp_dirent;
+    struct dirent *         tmp_dirent;
    struct dirent *         p;
+    size_t len;


    if(gmxdir!=NULL && gmxdir->dirent_handle!=NULL)
    {
-        rc = readdir_r(gmxdir->dirent_handle,&tmp_dirent,&p);
+        len  = offsetof(struct dirent, d_name)
+               + fpathconf(dirfd(gmxdir->dirent_handle), _PC_NAME_MAX) + 1;
+        smalloc(tmp_dirent, len);
+        rc = readdir_r(gmxdir->dirent_handle,tmp_dirent,&p);
+
        if(p!=NULL && rc==0)
        {
-            strncpy(name,tmp_dirent.d_name,maxlength_name);
+            strncpy(name,tmp_dirent->d_name,maxlength_name);
        }
        else
        {
            name[0] = '\0';
            rc      = ENOENT;
        }
+        sfree(tmp_dirent);
    }
    else
    {
########################################

> Also why the make -j 48, when you only have 8 cores?

We have 8 6-core CPUs (48 cores total).

> I'm not even sure if the linker is ok with make -jN for building gromacs,
it
> is not listed as compatible for *BSD ports. Also, does your make (I
imagine
> this is Solaris make) have all the same semantics as gnu-make (gmake)?

We are using GNU make.

> And why did you switch your CC between fftw and gromacs configures?
> Solaris 'cc' may or may not be gcc43. Also, do we know if gcc43 is stable
> especially with -O3...Try removing -O3 or move it to -O2 at most...

The Sun Studio 12.1 C compiler worked for fftw, but not for gromacs.

> To rule out a bad fftw library, you can set --with-fft to use the builtin
> (slower) libfft instead of fftw (but fftw should not be affecting pdb2gmx
> I don't think...).
>
> I too have the questions of your CFLAGS, do you not require -m64 either?

With gcc 4.3, there was a compilation error when -m64 was added to CFLAGS:

###################################################
make[5]: Entering directory
`/tmp//gromacs-4.5.4/src/gmxlib/nonbonded/nb_kernel_ia32_sse'
/bin/sh ../../../../libtool   --mode=compile gcc-4.3.2   -m64 -g
-msse2 -std=gnu99 -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -pthread
-I./include -c -o nb_kernel010_ia32_sse.lo nb_kernel010_ia32_sse.s
 gcc-4.3.2 -m64 -g -msse2 -std=gnu99 -D_POSIX_PTHREAD_SEMANTICS
-D_REENTRANT -pthread -I./include -c nb_kernel010_ia32_sse.s  -fPIC
-DPIC -o .libs/nb_kernel010_ia32_sse.o
nb_kernel010_ia32_sse.s: Assembler messages:
nb_kernel010_ia32_sse.s:87: Error: suffix or operands invalid for `push'
nb_kernel010_ia32_sse.s:89: Error: suffix or operands invalid for `push'
nb_kernel010_ia32_sse.s:90: Error: suffix or operands invalid for `push'
nb_kernel010_ia32_sse.s:91: Error: suffix or operands invalid for `push'
nb_kernel010_ia32_sse.s:92: Error: suffix or operands invalid for `push'
nb_kernel010_ia32_sse.s:93: Error: suffix or operands invalid for `push'
nb_kernel010_ia32_sse.s:94: Error: suffix or operands invalid for `push'
nb_kernel010_ia32_sse.s:795: Error: suffix or operands invalid for `pop'
nb_kernel010_ia32_sse.s:796: Error: suffix or operands invalid for `pop'
nb_kernel010_ia32_sse.s:797: Error: suffix or operands invalid for `pop'
nb_kernel010_ia32_sse.s:798: Error: suffix or operands invalid for `pop'
nb_kernel010_ia32_sse.s:799: Error: suffix or operands invalid for `pop'
nb_kernel010_ia32_sse.s:800: Error: suffix or operands invalid for `pop'
nb_kernel010_ia32_sse.s:865: Error: suffix or operands invalid for `push'
nb_kernel010_ia32_sse.s:867: Error: suffix or operands invalid for `push'
nb_kernel010_ia32_sse.s:868: Error: suffix or operands invalid for `push'
nb_kernel010_ia32_sse.s:869: Error: suffix or operands invalid for `push'
nb_kernel010_ia32_sse.s:870: Error: suffix or operands invalid for `push'
nb_kernel010_ia32_sse.s:871: Error: suffix or operands invalid for `push'
nb_kernel010_ia32_sse.s:872: Error: suffix or operands invalid for `push'
nb_kernel010_ia32_sse.s:1344: Error: suffix or operands invalid for `pop'
nb_kernel010_ia32_sse.s:1345: Error: suffix or operands invalid for `pop'
nb_kernel010_ia32_sse.s:1346: Error: suffix or operands invalid for `pop'
nb_kernel010_ia32_sse.s:1347: Error: suffix or operands invalid for `pop'
nb_kernel010_ia32_sse.s:1348: Error: suffix or operands invalid for `pop'
nb_kernel010_ia32_sse.s:1349: Error: suffix or operands invalid for `pop'
make[5]: *** [nb_kernel010_ia32_sse.lo] Error 1
##############################################


-- 
****************************************
Ragothaman M Yennamalli, Ph.D.
Postdoctoral Research Associate
1012 Crop Genome Informatics Laboratory
Department of Genetics, Development and Cell Biology
Iowa State University
Ames, Iowa 50011-3260 USA

+1 515-294-8971 (Office)
+1 515-294-8280 (Fax)
+1 515-851-1016 (Mobile)

"When you can do the common things of life in an uncommon way, you will
command the attention of the world." -George Washington Carver

http://www.public.iastate.edu/~raghu/
http://www.artistrkrishnarao.com/

***************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://maillist.sys.kth.se/pipermail/gromacs.org_gmx-users/attachments/20110422/8dc8cbc3/attachment.html>


More information about the gromacs.org_gmx-users mailing list