villano-lab / nrCascadeSim

calculating the NR spectrum resulting from neutron-capture cascades.
MIT License
0 stars 1 forks source link

[Crash Report] realizeCascades does not gracefully handle requests for more data than `max_size()` #115

Open nuclearGoblin opened 1 month ago

nuclearGoblin commented 1 month ago

I am submitting a bug report.

This bug occurs in: realizeCascades

Expected behavior: realizeCascades should run without crashing.

Current behavior: realizeCascades instead terminates by SIGABRT after throwing std::bad_alloc.

Steps to reproduce:

  1. run realizeCascades -n 10000000000000 -o ~/Si_big_file.root ~/git/nrCascadeSim/levelfiles/v3_natSi.txt
  2. See the crash occur.

Other Information: It is unclear what part of the process is causing this signal. At first glance, it appears to be able to read the levelfile file but not to produce any data before crashing.

Relevant Output: Output with -v2 flag added below:

Seed used: 1174110687
MT Result: 0.887944
**************/home/rune/git/nrCascadeSim/levelfiles/v3_natSi.txt***************

Cascade ID: 1/14
Fraction of this cascade: 0.625846
Neutron separation: 8.47356
Mass number: 29
Number of steps: 2

Energy Levels (keV)     |       tau (fs)
------------------------------------------------
      *****                      *****
      4934.4                     0.84
      0                  1e+14

Cascade ID: 2/14
Fraction of this cascade: 0.10722
Neutron separation: 8.4736
Mass number: 29
Number of steps: 3

Energy Levels (keV)     |       tau (fs)
------------------------------------------------
      *****                      *****
      6380.6                     0.36
      4840.3                     3.5
      0                  1e+14

Cascade ID: 3/14
Fraction of this cascade: 0.067778
Neutron separation: 8.4736
Mass number: 29
Number of steps: 2

Energy Levels (keV)     |       tau (fs)
------------------------------------------------
      *****                      *****
      1273.4                     291
      0                  1e+14

Cascade ID: 4/14
Fraction of this cascade: 0.039706
Neutron separation: 8.4736
Mass number: 29
Number of steps: 2

Energy Levels (keV)     |       tau (fs)
------------------------------------------------
      *****                      *****
      6380.6                     0.36
      0                  1e+14

Cascade ID: 5/14
Fraction of this cascade: 0.038974
Neutron separation: 8.4736
Mass number: 29
Number of steps: 3

Energy Levels (keV)     |       tau (fs)
------------------------------------------------
      *****                      *****
      4934.4                     0.84
      1273.4                     291
      0                  1e+14

Cascade ID: 6/14
Fraction of this cascade: 0.020846
Neutron separation: 8.4736
Mass number: 29
Number of steps: 1

Energy Levels (keV)     |       tau (fs)
------------------------------------------------
      *****                      *****
      0                  1e+14

Cascade ID: 7/14
Fraction of this cascade: 0.015106
Neutron separation: 10.609
Mass number: 30
Number of steps: 2

Energy Levels (keV)     |       tau (fs)
------------------------------------------------
      *****                      *****
      6744.1                     14
      0                  1e+14

Cascade ID: 8/14
Fraction of this cascade: 0.014053
Neutron separation: 6.5874
Mass number: 31
Number of steps: 3

Energy Levels (keV)     |       tau (fs)
------------------------------------------------
      *****                      *****
      3532.9                     6.9
      752.2                      530
      0                  1e+14

Cascade ID: 9/14
Fraction of this cascade: 0.012015
Neutron separation: 10.609
Mass number: 30
Number of steps: 3

Energy Levels (keV)     |       tau (fs)
------------------------------------------------
      *****                      *****
      7507.8                     24
      2235.3                     215
      0                  1e+14

Cascade ID: 10/14
Fraction of this cascade: 0.004006
Neutron separation: 10.609
Mass number: 30
Number of steps: 2

Energy Levels (keV)     |       tau (fs)
------------------------------------------------
      *****                      *****
      8163.2                     0.0018572
      0                  1e+14

Cascade ID: 11/14
Fraction of this cascade: 0.003513
Neutron separation: 6.5874
Mass number: 31
Number of steps: 3

Energy Levels (keV)     |       tau (fs)
------------------------------------------------
      *****                      *****
      5281.4                     0.010639
      752.2                      530
      0                  1e+14

Cascade ID: 12/14
Fraction of this cascade: 0.003412
Neutron separation: 10.609
Mass number: 30
Number of steps: 1

Energy Levels (keV)     |       tau (fs)
------------------------------------------------
      *****                      *****
      0                  1e+14

Cascade ID: 13/14
Fraction of this cascade: 0.002625
Neutron separation: 6.5874
Mass number: 31
Number of steps: 3

Energy Levels (keV)     |       tau (fs)
------------------------------------------------
      *****                      *****
      4382.4                     0.020661
      752.2                      530
      0                  1e+14

Cascade ID: 14/14
Fraction of this cascade: 0.000303
Neutron separation: 6.5874
Mass number: 31
Number of steps: 1

Energy Levels (keV)     |       tau (fs)
------------------------------------------------
      *****                      *****
      0                  1e+14

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
fish: Job 1, 'realizeCascades -v2 -n 10000000…' terminated by signal SIGABRT (Abort)
nuclearGoblin commented 1 month ago

Reducing the length by an order of magnitude (1000000000000 instead of 10000000000000) makes the error a bit more clear (same place, no -v2 flag for brevity):

Seed used: 657501263
MT Result: 0.319352
terminate called after throwing an instance of 'std::length_error'
  what():  cannot create std::vector larger than max_size()
fish: Job 1, 'realizeCascades -n 100000000000…' terminated by signal SIGABRT (Abort)

At some point in the past we were able to generate larger files -- not sure what has changed? Anyway, we should probably write code that detects the size issue and does one of the following: