svenreiche / Genesis-1.3-Version4

Time-dependent, 3D Code to simulate the amplification process of a Free-electron Laser.
GNU General Public License v3.0
53 stars 26 forks source link

libc++abi: terminating due to uncaught exception #134

Closed ChristopherMayes closed 7 months ago

ChristopherMayes commented 8 months ago

Describe the bug I get the following with a simple example:

---------------------------------------------
GENESIS - Version 4.6.5 has started...
Compile info: Compiled by runner at 2023-12-22 15:23:54 [UTC] from Git Commit ID: 
Starting Time: Sat Dec 23 08:31:55 2023

MPI-Comm Size: 1 node

Opened input file genesis4.in
Parsing lattice file genesis4_drift.lat ...
Setting up time window of 71.8 microns with 718 sample points...
Adding profile with label: beamcurrent
Generating input particle distribution...

Running Core Simulation...
Time-dependent run with 718 slices for a time window of 71.8 microns
Initial analysis of electron beam and radiation field...
  Calculation: 0% done
Writing output file...

Core Simulation done.
End of Track
Writing particle distribution to file: end.par.h5 ...
libc++abi: terminating due to uncaught exception of type std::out_of_range: vector
./run: line 1: 38534 Abort trap: 6           genesis4 genesis4.in

To Reproduce Run genesis4 genesis4.in on the attached files

error.zip

ken-lauer commented 7 months ago

This is being thrown on this line: https://github.com/svenreiche/Genesis-1.3-Version4/blob/694c1d0c7d9d6a49f93e88ecc5629f9f4d970bce/src/IO/writeBeamHDF5.cpp#L92

This happens at beam->beam.at(islice).at(ip*stride) where ip*stride=128 is over the number of particles (127). npart is also 256, which means this isn't just an off-by-one error.

The input file states npart 128, so where is npart = 256 coming in? Hmm...

ken-lauer commented 7 months ago

git bisect indicates 88f7200c13ce2e929cf725fa3857a56ae946acf5 is the commit that introduced this issue:

$ git bisect good
88f7200c13ce2e929cf725fa3857a56ae946acf5 is the first bad commit
commit 88f7200c13ce2e929cf725fa3857a56ae946acf5
Author: reiche <sven.reiche@psi.ch>
Date:   Wed Dec 6 15:17:12 2023 +0100

    Added downsamplig ability for particle dumps.

 CHANGELOG.md             | 10 +++++++++-
 include/writeBeamHDF5.h  |  2 +-
 manual/MAIN_INPUT.md     |  1 +
 src/Core/Control.cpp     |  2 +-
 src/IO/writeBeamHDF5.cpp | 20 +++++++++++---------
 src/Main/Dump.cpp        |  7 ++++++-
 6 files changed, 29 insertions(+), 13 deletions(-)