[AMBER] possible bug - SIGSEGV in cpptraj called from MMPBSA.py

From: Andrzej Dorobisz via AMBER <amber.ambermd.org>
Date: Tue, 6 Dec 2022 11:31:57 +0100

Hello,
In our HPC centre one of our users encountered SIGSEGV using cpptraj
program (which was called from MMPBSA.py). We traced it, isolated
cpptraj call and collected debug information. Could you take a look at
this - is it a bug in the code or problem with the input data?

*Details*

backtrace:
> # function args file                              line
> --  ----------------------------
> ------------------------------------------------
> --------------------------------  ----
> #0  __memmove_avx_unaligned_erms () /lib64/libc.so.6
> #1  Frame::SetCoordinates (this=0x2696cb0,frameIn=...,maskIn=...)
> src/cpptraj/src/Frame.cpp         558
> #2  Action_Rmsd::DoAction (this=0x2696490,frameNum=221452,frm=...)
> src/cpptraj/src/Action_Rmsd.cpp   368
> #3  ActionList::DoActions
> (this=0x7fff0417cc98,frameNumIn=221452,frm=...)
> src/cpptraj/src/ActionList.cpp    94
> #4  CpptrajState::RunNormal (this=0x7fff0417cb60)
> src/cpptraj/src/CpptrajState.cpp  1354
> #5  CpptrajState::Run (this=0x7fff0417cb60)
> src/cpptraj/src/CpptrajState.cpp  500
> #6  Cpptraj::RunCpptraj
> (this=0x7fff0417cb60,argc=2,argv=0x7fff0417d048)
> src/cpptraj/src/Cpptraj.cpp       166
> #7  CpptrajProgram (argc=2,argv=0x7fff0417d048)
> src/cpptraj/src/main.cpp          18
> #8  main (argc=2,argv=0x7fff0417d048) src/cpptraj/src/main.cpp          30

amber version:
- backtrace collected with Amber 22.1 and AmberTools 22.3 (compiled with
-DOPTIMIZE=OFF and -O0 -g)
(we have tested also previous versions of Amber and they all fail on
user input)

direct command:
cat input-cpptraj.txt | cpptraj E81A.top

commands in the input-cpptraj.txt:
> trajin ../input/E81A.nc 1 224999 1
> noprogress
> rmsd !(:WAT,Cl*,CIO,Cs+,IB,K*,Li+,MG*,Na+,Rb+,CS,RB,NA,F,CL) mass first
> outtraj _MMPBSA_complex.pdb onlyframes 1 nobox pdb
> outtraj _MMPBSA_dummycomplex.inpcrd onlyframes 1 nobox restart
> outtraj _MMPBSA_complex.mdcrd.0 onlyframes 1-224999 nobox
> strip :288
> outtraj _MMPBSA_receptor.pdb onlyframes 1 nobox pdb
> outtraj _MMPBSA_dummyreceptor.inpcrd onlyframes 1 nobox restart
> outtraj _MMPBSA_receptor.mdcrd.0 onlyframes 1-224999 nobox
> unstrip
> rmsd !(:WAT,Cl*,CIO,Cs+,IB,K*,Li+,MG*,Na+,Rb+,CS,RB,NA,F,CL) mass first
> strip :1-287,289-576
> outtraj _MMPBSA_ligand.pdb onlyframes 1 nobox pdb
> outtraj _MMPBSA_dummyligand.inpcrd onlyframes 1 nobox restart
> outtraj _MMPBSA_ligand.mdcrd.0 onlyframes 1-224999 nobox
> unstrip
> rmsd !(:WAT,Cl*,CIO,Cs+,IB,K*,Li+,MG*,Na+,Rb+,CS,RB,NA,F,CL) mass first

The call that causes SIGSEGV is the memcpy call.

> void Frame::SetCoordinates(Frame const& frameIn, AtomMask const& maskIn) {
>
>   (...)
>
>   for (AtomMask::const_iterator atom = maskIn.begin(); atom !=
> maskIn.end(); ++atom)
>   {
>     memcpy( newXptr, frameIn.X_ + ((*atom) * 3), COORDSIZE_);        
>             // <= SIGSEGV here!
>     newXptr += 3;
>   }
> }

I checked with GDB that the problem is caused by a negative value of the
source address in the memcpy call (second arg). Such a value is a
consequence of an invalid index in the "Selected_" vector of the
"maskIn" (to which the "atom" iterator points).

First values of "maskIn.Selected_":
{775042866, 3158064, 2, 3, 4, 5, 6, 7, 8, 9, ...}

So the real question is what could have caused to get such a monster
here....


---
Finally, I would like to point out a minor issue in the MMPBSA.py code.
When cpptraj fails, then MMPBSA.py also fails, but with the following 
backtrace:
> Loading and checking parameter files for compatibility...
> cpptraj found! Using 
> /net/software/testing/software/Amber/22.1-intel-2021b-AmberTools-22.3/bin/cpptraj
> sander found! Using 
> /net/software/testing/software/Amber/22.1-intel-2021b-AmberTools-22.3/bin/sander
> Preparing trajectories for simulation...
> free(): invalid next size (normal)
>   File 
> "/net/software/testing/software/Amber/22.1-intel-2021b-AmberTools-22.3/bin/MMPBSA.py.MPI", 
> line 99, in <module>
>     app.file_setup()
>   File 
> "/net/software/testing/software/Amber/22.1-intel-2021b-AmberTools-22.3/lib/python3.9/site-packages/MMPBSA_mods/main.py", 
> line 155, in file_setup
>     self.numframes, self.numframes_nmode = make_trajectories(INPUT, FILES,
>   File 
> "/net/software/testing/software/Amber/22.1-intel-2021b-AmberTools-22.3/lib/python3.9/site-packages/MMPBSA_mods/make_trajs.py", 
> line 134, in make_trajectories
>     traj.Run(pre + 'normal_traj_cpptraj.out')
>   File 
> "/net/software/testing/software/Amber/22.1-intel-2021b-AmberTools-22.3/lib/python3.9/site-packages/MMPBSA_mods/make_trajs.py", 
> line 687, in Run
>     raise TrajError('Error running %s' % self.program)
> AttributeError: 'Trajectory' object has no attribute 'program'
> Error occurred on rank 0.
So actually, there is a bug in make_trajs.py code, because the 
Trajectory object does not have a field named "program".
---
Looking forward to you help,
Andrzej Dorobisz
HPC Software Department
ACC Cyfronet AGH, Poland
_______________________________________________
AMBER mailing list
AMBER.ambermd.org
http://lists.ambermd.org/mailman/listinfo/amber
Received on Tue Dec 06 2022 - 03:00:03 PST
Custom Search