Gem example does not open vis interface

Hi everyone!
This is my first post in the ROOT community and I want to thank you all for the help I get by reading the forum for years.
Now I success installing Garfieldpp on Archlinux from source, then when I run the example gem.c the simulation starts, it opens the ROOT visual interface too, but just after some seconds I got this strange C++ error:

/usr/include/c++/14.2.1/bits/stl_vector.h:1130: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = double; _Alloc = std::allocator<double>; reference = double&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.
[1]    335004 IOT instruction (core dumped)  ./gem

The previous lines contains - I think - the correct output of gem.c.
I tried searching online but I didn’t find anything helpful.
Do you know how I can solve this? Thank you!

Hello Mattia, probably @hschindl can help you with this.

Meanwhile, if you can provide a full stack trace that may help with debugging the issue.

Thank you @silverweed! The following are the output line of gem.c:

~/Documents/MC/Garfield Examples/Gem/build]$ ./gem                                                                                                                        
MediumMagboltz::SetComposition: Ar/CO2 (80/20)
MediumMagboltz::Mixer:
    4000 linear energy steps between 0 and 40 eV.
    ARGON ANISOTROPIC    2014
      mass: 39.948 amu
      ionisation threshold: 15.7596 eV
      44 inelastic terms (44 excitations, 0 superelastic, 0 other)
    CO2  2018 ANISOTROPIC    
      mass: 44.0095 amu
      ionisation threshold: 13.776 eV
      144 inelastic terms (0 excitations, 35 superelastic, 109 other)
MediumMagboltz::Mixer:
    Lowest ionisation threshold in the mixture: 13.776 eV (CO2)
MediumMagboltz::Mixer:
    Energy [eV]    Collision Rate [ns-1]
          2.50               1068.85
          7.50               2892.41
         12.50               5363.62
         17.50               8777.02
         22.50              11300.56
         27.50              12660.82
         32.50              12521.53
         37.50              12101.91
MediumMagboltz::ComputePhotonCollisionTable:
    Energy [eV]      Mean free path [um]
          1.00          ------------
          3.00          ------------
          5.00          ------------
          7.00           288302.9619
          9.00             3279.0615
         11.00               23.1076
         13.00               31.4118
         15.00              145.1898
         17.00               13.2429
         19.00               11.1775
MediumMagboltz::EnablePenningTransfer:
    Warning: present gas table has no ionisation rates.
    Ignore this message if you are using microscopic tracking only.
MediumMagboltz::EnablePenningTransfer:
    Penning transfer probability for 44 Ar excitation levels set to r = 0.51
MediumMagboltz::LoadMobility:
    Read 36 values from file /home/okabe/garfield/install/share/Garfield/Data/IonMobility_Ar+_Ar.txt
ComponentAnsys123::Initialise:
    Read properties of 3 materials from file MPLIST.lis.
    Read 8758 elements from file ELIST.lis.
    Highest node number: 14066
    Background elements skipped: 0
    Read 14066 nodes from file NLIST.lis.
    Read 14066 potentials from file PRNSOL.lis.
ComponentAnsys123::Prepare:
    Caching the bounding boxes of all elements... done.
    Initialized tetrahedral tree.
ComponentAnsys123::PrintRange:
        Dimensions of the elementary block
                          0 < x < 0.007           cm,
                          0 < y < 0.0121244       cm,
                       -0.1 < z < 0.1             cm,
                       -200 < V < 350             V.
        Periodicities
            x: mirror with length 0.007 cm
            y: mirror with length 0.0121244 cm
            z: none
ComponentAnsys123::SetGas: Associating material 1 with Ar/CO2.
ComponentAnsys123::PrintMaterials:
    Currently 3 materials are defined.
      Index Permittivity  Resistivity Notes
          0        1e+10            0
          1            1           -1 Ar/CO2, drift medium, ionisable (drift medium)
          2            4           -1
/usr/include/c++/14.2.1/bits/stl_vector.h:1130: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = double; _Alloc = std::allocator<double>; reference = double&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.
[1]    468606 IOT instruction (core dumped)  ./gem

I am using ArchLinux with KDE Plasma (Wayland, not X11 if ti has something to do with it) on a Dell laptop.
CPU: 11th Gen Intel(R) Core™ i7-11800H
GPU: NVIDIA RTX 3050Ti Laptop

I’ve used ROOT and Geant4 for months without any problem. Geant4 and Garifled are source installed, while ROOT by the AUR package (maybe I will change it to a source installation too).
The only one problem I have with ROOT is with the X11 (–web=off option) visualization that does not let me change the font format, so that I read nothing of the menu…
For Garfield I’ve just specified the installation folder to be:

-DCMAKE_INSTALL_PREFIX=$GARFIELD_HOME/install

I sourced the .sh file too.

Thank you for the help again!

EDIT: I forgot to say that I found the same C++ library problem on another software’s forum, I understand that - perhaps - there is a default CXXFLAGS option in conflict with Garfield.

Hi,
thanks for reporting this! The message seems to suggest that there is a bug somewhere in the code (trying to access an element greater than the size of the vector). Could you try to run gdb to see where this happens?

Hi,
if I did it correctly this is the only error:

/usr/include/c++/14.2.1/bits/stl_vector.h:1130: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = double; _Alloc = std::allocator<double>; reference = double&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.

Program received signal SIGABRT, Aborted.
Downloading 4.06 K source file /usr/src/debug/glibc/glibc/nptl/pthread_kill.c
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6,               
    no_tid=no_tid@entry=0) at pthread_kill.c:44
44            return INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO (ret) : 0;

Hi,
thanks a lot and sorry for my late reply! Could you rebuild the project in DEBUG mode and try again?

Hi,
I really appreciate your help. I’m quite a newbie about debugging. Do you mean running cmake in debug mode? How can I do it?

Hi,
yes, exactly; I meant add -DCMAKE_BUILD_TYPE=Debug or -DCMAKE_BUILD_TYPE= RelWithDebInfo when you run cmake to build Garfield++.

okay then I ran cmake -DCMAKE_BUILD_TYPE=Debug .., ran make and when I execute with gdb I get the exact same message I sent before:

/usr/include/c++/14.2.1/bits/stl_vector.h:1130: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = double; _Alloc = std::allocator<double>; reference = double&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.

Program received signal SIGABRT, Aborted.
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
44            return INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO (ret) : 0;

However, I noticed that if I set to false this boolean (that originally is true) around line 70 of the gem example:

meshView.SetFillMesh(false);

it works fine. The only difference is on the electric potential plot, since the gray trapezoids are not filled while they should be:

Thanks a lot! That’s already very helpful; I will take a look if I see something suspicious in this class…

Oh furthermore, my colleague has a Rocky Linux virtual machine with C++ version 11 (mine is 14.2.1), I help him installing garfield and it works perfectly fine! :smiling_face_with_tear:
It could be a specific problem of my gcc version… I’ll try to install the v11 too to test this theory.