[gmx-developers] Memory allocation bug in g_traj (cvs + 3.3.1)

hessb at mpip-mainz.mpg.de hessb at mpip-mainz.mpg.de
Wed Jul 11 18:43:05 CEST 2007

>> Hello All,
>> I encountered a little (and easy to fix) bug in gmx_traj.c,
>> in cvs it is at line 571, in 3.3.1 line 553.
>> -> isize[i] = atndx[index0[0][i]+1] - atndx[index0[0][i]];
>> isize[i] can become negative in some cases what results in the attempt
>> to pass a negative number to sfree() and thus a crash.
> I guess you mean snew()?
>> This is easily fixed by just adding behind the above line.
>> if (isize[i] < 0)
>>   isize[i] = isize[i] * -1;
>> Regards,
>> Wolfram
> But isize[i] should never become negative, unless you pass
> an incorrect molecule number (<1 or >#mols).
> So we should add a check for that instead of your fix.
> Or am I wrong?
> Berk.

Ah, now I looked again I see the code is actually incorrect.
The atndx should not be used to determine the isize.
But I think this would only go wrong with a shuffled system.
Did you use grompp -shuffle?


More information about the gromacs.org_gmx-developers mailing list