Example RPCSpaceCharge

Hello
I hope you are doing well
when i run example RPCSpaceCharge
it crashes

Start RPC Space Charge Example
MediumMagboltz::LoadGasFile:
    Reading file CO2_C2H2F4_isoC4H10_SF6_30_64.5_4.5_1_T_293_P_723.8.gas.
    Version 12.
    Gas composition set to iC4H10/CO2/SF6/C2H2F4 (4.5/30/1/64.5).
MediumMagboltz::Mixer:
    4000 linear energy steps between 0 and 100 eV.
    ISO-C4H10 2014 ANISOTRPIC
      mass: 58.1234 amu
      ionisation threshold: 10.67 eV
      24 inelastic terms (15 excitations, 4 superelastic, 5 other)
    CO2  2018 ANISOTROPIC    
      mass: 44.0095 amu
      ionisation threshold: 13.776 eV
      144 inelastic terms (0 excitations, 35 superelastic, 109 other)
     SF6 2014  ANISOTROPIC   
      mass: 146.055 amu
      ionisation threshold: 15.67 eV
      35 inelastic terms (25 excitations, 3 superelastic, 7 other)
     C2H2F4 2024 ANISOTROPIC 
      mass: 102.031 amu
      ionisation threshold: 13.2 eV
      19 inelastic terms (10 excitations, 4 superelastic, 5 other)
MediumMagboltz::Mixer:
    Lowest ionisation threshold in the mixture: 10.67 eV (iC4H10)
MediumMagboltz::Mixer:
    Energy [eV]    Collision Rate [ns-1]
          6.25               6603.09
         18.75               9972.31
         31.25              12526.93
         43.75              15972.04
         56.25              18411.13
         68.75              20074.92
         81.25              21566.86
         93.75              22922.28
MediumMagboltz::ComputePhotonCollisionTable:
    Photoabsorption cross-section for iC4H10 not available.
    Using n-butane cross-section instead.
ComponentParallelPlateSetup: Geometry with N = 5 layers set.
ComponentParallelPlate::AddPlane: Added plane electrode.
Sensor::AddElectrode:
    Added readout electrode "readout".
    All signals are reset.
Sensor::SetTimeWindow: Resetting all signals.

 *** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00007f14305803ea in __GI___wait4 (pid=94662, stat_loc=stat_loc
entry=0x7ffe724ecd58, options=options
entry=0, usage=usage
entry=0x0) at ../sysdeps/unix/sysv/linux/wait4.c:30
#1  0x00007f14305803ab in __GI___waitpid (pid=<optimized out>, stat_loc=stat_loc
entry=0x7ffe724ecd58, options=options
entry=0) at ./posix/waitpid.c:38
#2  0x00007f14304e6bdb in do_system (line=<optimized out>) at ../sysdeps/posix/system.c:171
#3  0x00007f1430c23e06 in TUnixSystem::StackTrace() () from /home/hemida/ROOT/root_install/lib/libCore.so
#4  0x00007f1430c21135 in TUnixSystem::DispatchSignals(ESignals) () from /home/hemida/ROOT/root_install/lib/libCore.so
#5  <signal handler called>
#6  0x00007f14317193f2 in std::vector<std::tuple<Garfield::Component*, bool, bool>, std::allocator<std::tuple<Garfield::Component*, bool, bool> > >::size() const () from /media/hemida/1cc58363-acf6-447b-82c3-bf613d1143c7/yasser/Downloads/garfield/garfieldpp_install/lib/libGarfield.so.0.3
#7  0x00007f14317189e6 in Garfield::Sensor::GetNumberOfComponents() const () from /media/hemida/1cc58363-acf6-447b-82c3-bf613d1143c7/yasser/Downloads/garfield/garfieldpp_install/lib/libGarfield.so.0.3
#8  0x00007f143171fff4 in Garfield::AvalancheGridSpaceCharge::SetSensor(Garfield::Sensor*) () from /media/hemida/1cc58363-acf6-447b-82c3-bf613d1143c7/yasser/Downloads/garfield/garfieldpp_install/lib/libGarfield.so.0.3
#9  0x00007f143171fad6 in Garfield::AvalancheGridSpaceCharge::AvalancheGridSpaceCharge(Garfield::Sensor*) () from /media/hemida/1cc58363-acf6-447b-82c3-bf613d1143c7/yasser/Downloads/garfield/garfieldpp_install/lib/libGarfield.so.0.3
#10 0x0000562a3996e8a5 in Garfield::AvalancheGridSpaceCharge::AvalancheGridSpaceCharge() ()
#11 0x0000562a3996ddb0 in main ()
===========================================================


The lines below might hint at the cause of the crash. If you see question
marks as part of the stack trace, try to recompile with debugging information
enabled and export CLING_DEBUG=1 environment variable before running.
You may get help by asking at the ROOT forum https://root.cern/forum
preferably using the command (.forum bug) in the ROOT prompt.
Only if you are really convinced it is a bug in ROOT then please submit a
report at https://root.cern/bugs or (preferably) using the command (.gh bug) in
the ROOT prompt. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#6  0x00007f14317193f2 in std::vector<std::tuple<Garfield::Component*, bool, bool>, std::allocator<std::tuple<Garfield::Component*, bool, bool> > >::size() const () from /media/hemida/1cc58363-acf6-447b-82c3-bf613d1143c7/yasser/Downloads/garfield/garfieldpp_install/lib/libGarfield.so.0.3
#7  0x00007f14317189e6 in Garfield::Sensor::GetNumberOfComponents() const () from /media/hemida/1cc58363-acf6-447b-82c3-bf613d1143c7/yasser/Downloads/garfield/garfieldpp_install/lib/libGarfield.so.0.3
#8  0x00007f143171fff4 in Garfield::AvalancheGridSpaceCharge::SetSensor(Garfield::Sensor*) () from /media/hemida/1cc58363-acf6-447b-82c3-bf613d1143c7/yasser/Downloads/garfield/garfieldpp_install/lib/libGarfield.so.0.3
#9  0x00007f143171fad6 in Garfield::AvalancheGridSpaceCharge::AvalancheGridSpaceCharge(Garfield::Sensor*) () from /media/hemida/1cc58363-acf6-447b-82c3-bf613d1143c7/yasser/Downloads/garfield/garfieldpp_install/lib/libGarfield.so.0.3
#10 0x0000562a3996e8a5 in Garfield::AvalancheGridSpaceCharge::AvalancheGridSpaceCharge() ()
#11 0x0000562a3996ddb0 in main ()
===========================================================

I’m sure @hschindl can help

Hi,
many thanks for reporting this issue and apologies for the inconvenience!
I’ve just committed a fix: Protect against nullptr. (!497) · Merge requests · garfield / garfieldpp · GitLab

As a workaround, you can also replace the line

AvalancheGridSpaceCharge avalsc;

by

AvalancheGridSpaceCharge avalsc(&sens);
2 Likes