I have been using RASPA for the past few months, and recently I started incorporating the charge equilibration feature in my simulation pipeline. Initially, everything went fine, but then I started having problems.
When the ChargeFromChargeEquilibration option is set to yes, the simulation crashes with a Segmentation Fault for some (but not all) CIF files.
SimulationType MonteCarlo
NumberOfCycles 0
Framework 0
FrameworkName TER
UnitCells 3 2 2
ChargeFromChargeEquilibration yes
ChargeEquilibrationPeriodic yes
ChargeEquilibrationEwald yes
SymmetrizeFrameworkCharges no
The purpose of this MonteCarlo simulation is simply to create a new CIF file containing a 3x2x2 supercell with P1 symmetry.
To help with debugging, I recompiled RASPA v2.0.39 with CFLAGS="-w -ggdb -O0" and executed
$ gdb ~/RASPA2-2.0.39/bin/simulate
(gdb) run
Starting program: ~/RASPA2-2.0.39/bin/simulate
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff6492e18 in __strcpy_sse2_unaligned () from /lib64/libc.so.6
(gdb) bt
#0 0x00007ffff6492e18 in __strcpy_sse2_unaligned () from /lib64/libc.so.6
#1 0x00007ffff718e543 in WriteFrameworkDefinitionShell (string=0x7ffff7bff6f8 "initial") at framework.c:2103
#2 0x00007ffff793de5e in run (inputData=0x408910 "simulation.input", inputCrystal=0x408930 "",
raspaDir=0x7fffffffd8cb "~/RASPA2-2.0.39/", stream=false) at run.c:101
#3 0x00000000004013e1 in main (argc=1, argv=0x7fffffffd398) at main.c:106
(gdb) frame 1
#1 0x00007ffff718e543 in WriteFrameworkDefinitionShell (string=0x7ffff7bff6f8 "initial") at framework.c:2103
2103 strcpy(symbol,PseudoAtoms[Type].ChemicalElement);
(gdb) p Type
$2 = -415391835
(gdb) p PseudoAtoms[Type].ChemicalElement
Cannot access memory at address 0xffffffce7b817de4
I notice that both Type and OriginalType are negative, but AssymetricType is positive.
I have read here several times that is typically something in the CIF files that generates these Segmentation Faults. I also agree that is probably easier to fix the non-standard CIF rather than implementing safeguards in the code to deal with rare situations. I hope that I was able to pinpoint the issue well enough to make it easier for the experts identify its origin. I also posted this in the iRASPA Forum.
Is there anything we can do (preferably) to the CIF file (otherwise, to the code itself) to prevent this Segmentation Fault from happening?
Hello everyone!
I have been using RASPA for the past few months, and recently I started incorporating the charge equilibration feature in my simulation pipeline. Initially, everything went fine, but then I started having problems.
When the
ChargeFromChargeEquilibration
option is set toyes
, the simulation crashes with a Segmentation Fault for some (but not all) CIF files.One example of a CIF file that leads to a crash is
TER.cif
from the Database of Zeolite Structures: https://asia.iza-structure.org/IZA-SC/cif/TER.cif.The
simulation.input
file is as simple asThe purpose of this
MonteCarlo
simulation is simply to create a new CIF file containing a 3x2x2 supercell with P1 symmetry.To help with debugging, I recompiled RASPA v2.0.39 with
CFLAGS="-w -ggdb -O0"
and executedThe source of the Segmentation Fault seems to be that we are trying to access the
PseudoAtoms
array at a negative index (Type = -415391835
), which does not exist. This occurs at https://github.com/iRASPA/RASPA2/blob/master/src/framework.c#L2103.So I investigated further why/where the
Type
index variable was set to a negative value and found it at https://github.com/iRASPA/RASPA2/blob/master/src/framework.c#L2101.I notice that both
Type
andOriginalType
are negative, butAssymetricType
is positive.I have read here several times that is typically something in the CIF files that generates these Segmentation Faults. I also agree that is probably easier to fix the non-standard CIF rather than implementing safeguards in the code to deal with rare situations. I hope that I was able to pinpoint the issue well enough to make it easier for the experts identify its origin. I also posted this in the iRASPA Forum.
Is there anything we can do (preferably) to the CIF file (otherwise, to the code itself) to prevent this Segmentation Fault from happening?