Project

General

Profile

Bug #310

Segmanetaion fault during attempted xdrfile_close in libxdrfile

Added by Ran Friedman over 10 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Normal
Category:
mdrun
Target version:
Affected version - extra info:
Affected version:
Difficulty:
uncategorized
Close

Description

I've downloaded and installed libxdrfile from the CVS and started to write a C code that uses some of the functions.

Basically, the code goes frame by frame over an xtc file to get the number of frames etc., then close the xtc file.

I've started testing it on an xtc file with a single frame. I have the following line:

[code]
result=read_xtc(xtc,natom,&step,&time,box,x,&precision);
[end]

Which returns exdrOK after the first readout and exdrINT after the second.
Then when I try to close the file I get the following error:
  • glibc detected * munmap_chunk(): invalid pointer: 0x0000000000634700 *

Which occurs in the xdrfile_close function (xdrfile.c):
[code, lines 244 - 263 ]
int
xdrfile_close(XDRFILE *xfp) {
int ret=exdrCLOSE;
if(xfp) {
/* flush and destroy XDR stream /
if(xfp->xdr)
xdr_destroy((XDR *)(xfp->xdr));
free(xfp->xdr);
/
close the file /
ret=fclose(xfp->fp);
if(xfp->buf1size)
free(xfp->buf1); /
<== free fails here /
if(xfp->buf2size)
free(xfp->buf2);
free(xfp);
}
return ret; /
return 0 if ok */
}
[end]

the call for "free" fails for releasing the memory from xfp->buf1 (line 257, indicated).

My system is SUSE LINUX 10.1, 64bit, gcc 4.1.0.
Gromacs runs without any apparent problem on the same machine, and gmxcheck had no trouble with the xtc file.

I'd appreciate any advise.

Ran.

History

#1 Updated by David van der Spoel over 10 years ago

Hi Ran,

could you please test whether this bug is still there with the present CVS or the beta version (check http://wiki.gromacs.org/index.php/XTC_Library for a link).

#2 Updated by David van der Spoel over 10 years ago

this has been fixed in CVS.

Also available in: Atom PDF