Add -Wp,-D_GLIBCXX_ASSERTIONS to the build flags
As reported by Rob from Radiasoft (see below) Fedora (and also RHEL and derivatives?) adds "-Wp,-D_GLIBCXX_ASSERTIONS" to the build flags. This results, among other things, in checking the memory access in STL containers. In Opal we often use &someVector[0]
which can cause an assertion if the vector has no elements. Where it isn't guaranteed that the vector has elements we have to handle this situation (e.g. as in Boost::mpi ) to avoid an assertion failure in combination with _GLIBCXX_ASSERTIONS
.
From: Rob Nagler <opal-rtnkh@q33.us>
Date: Tue, 22 Dec 2020 17:04:55 -0700
Subject: Re: [Opal] Compiling issues (Fedora 32/gcc10)
Ran into another issue with Fedora 32. They've turned on code hardening (
discussion
<https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/TMDJMX2OYE7Z2WHKXMOMTOBDHJKZJ3NV/>)
so wrappers like mpicxx automatically include flags like
"-Wp,-D_GLIBCXX_ASSERTIONS", which in this case causes opal to fail to run,
because of an assertion failure in stl_vector. I've included the stack
below. I've worked around this by patching mpicxx & company, but I suspect
it might be useful to turn on _GLIBCXX_ASSERTIONS to find some latent bugs
in the code.
Cheers,
Rob
(gdb) run opal.in
Starting program: /home/vagrant/.local/bin/opal opal.in
Missing separate debuginfos, use: dnf debuginfo-install
glibc-2.31-4.fc32.x86_64
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Ippl> CommMPI: Parent process waiting for children ...
Ippl> CommMPI: Initialization complete.
> ____ _____ ___
> / __ \| __ \ /\ | |
> | | | | |__) / \ | |
> | | | | ___/ /\ \ | |
> | |__| | | / ____ \| |____
> \____/|_| /_/ \_\______|
OPAL>
OPAL> This is OPAL (Object Oriented Parallel Accelerator Library) Version
2.4.0
OPAL> git rev. unknown
OPAL>
OPAL>
OPAL> (c) PSI, http://amas.web.psi.ch
OPAL>
OPAL>
OPAL> The optimiser (former opt-Pilot) is integrated
OPAL>
OPAL> Please send cookies, goodies or other motivations (wine and beer ... )
OPAL> to the OPAL developers opal@lists.psi.ch
OPAL>
OPAL> Time: 23:59:38 date: 22/12/2020
OPAL>
OPAL> Couldn't find startup file "/home/vagrant/init.opal".
OPAL> Note: this is not mandatory for an OPAL simulation!
OPAL>
OPAL> * Reading input stream "opal.in".
OPAL> *
**********************************************************************************
OPAL> * Selected Tracking Method == PARALLEL-T, NEW TRACK
OPAL> *
**********************************************************************************
/usr/include/c++/10/bits/stl_vector.h:1045: std::vector<_Tp,
_Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp,
_Alloc>::size_type) [with _Tp = char; _Alloc = std::allocator<char>; \
std::vector<_Tp, _Alloc>::reference = char&; std::vector<_Tp,
_Alloc>::size_type = long unsigned int]: Assertion '__builtin_expect(__n <
this->size(), true)' failed.
Program received signal SIGABRT, Aborted.
0x00007ffff683e9e5 in raise () from /lib64/libc.so.6
Missing separate debuginfos, use: dnf debuginfo-install
blas-3.9.0-3.fc32.x86_64 bzip2-libs-1.0.8-2.fc32.x86_64
gsl-2.6-2.fc32.x86_64 hdf5-mpich-1.10.5-6.fc32.x86_64
hwloc-libs-2.0.4-3.fc32.x86_64 lapack\
-3.9.0-3.fc32.x86_64 libaec-1.0.4-3.fc32.x86_64 libgcc-10.2.1-6.fc32.x86_64
libgfortran-10.2.1-6.fc32.x86_64 libicu-65.1-2.fc32.x86_64
libquadmath-10.2.1-6.fc32.x86_64 libstdc++-10.2.1-6.fc32.x86_64 libt\
ool-ltdl-2.4.6-33.fc32.x86_64 mpich-3.3.2-4.fc32.x86_64
xz-libs-5.2.5-1.fc32.x86_64 zlib-1.2.11-21.fc32.x86_64
(gdb) bt
bt
#0 0x00007ffff683e9e5 in raise () from /lib64/libc.so.6
#1 0x00007ffff6827895 in abort () from /lib64/libc.so.6
#2 0x0000555555e9cb38 in std::__replacement_assert
(__file=__file@entry=0x5555578604d0
"/usr/include/c++/10/bits/stl_vector.h", __line=__line@entry=1045,
__function=__function@entry=0x555557880338 "std::vector<_Tp,
_Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp,
_Alloc>::size_type) [with _Tp = char; _Alloc = std::allocator<cha\
r>; std::vector<_Tp, _Alloc>::reference = cha"...,
__condition=__condition@entry=0x555557860370 "__builtin_expect(__n <
this->size(), true)")
at /usr/include/c++/10/x86_64-redhat-linux/bits/c++config.h:2560
#3 0x0000555556329045 in std::vector<char, std::allocator<char>
>::operator[] (__n=0, this=0x7fffffffb750) at
/usr/include/c++/10/bits/ios_base.h:170
#4 Distribution::createDistributionFromFile (this=0x5555585afe50,
massIneV=<optimized out>) at
/home/vagrant/src-OPAL-2.4.0/src/Distribution/Distribution.cpp:1109
#5 0x00005555563295f0 in Distribution::create (this=0x5555585afe50,
numberOfParticles=@0x555558616c70: 10000, massIneV=510998.95000000001,
charge=-1)
at /home/vagrant/src-OPAL-2.4.0/src/Distribution/Distribution.cpp:290
#6 0x000055555632a015 in Distribution::createOpalT (this=0x5555585afe50,
beam=0x5555585b3bb0, numberOfParticles=@0x7fffffffc228: 10000) at
/usr/include/c++/10/bits/stl_vector.h:1092
#7 0x00005555560a403c in PartBunchBase<double, 3u>::setDistribution
(np=@0x7fffffffc228: 10000, addedDistributions=..., d=<optimized out>,
this=0x5555585b3bb0)
at /usr/include/c++/10/bits/stl_algobase.h:560
#8 TrackRun::setDistributionParallelT (this=0x5555585b5ba0,
beam=0x5555585af8d0) at
/home/vagrant/src-OPAL-2.4.0/src/Track/TrackRun.cpp:680
#9 0x00005555560a9282 in TrackRun::setupTTracker (this=0x5555585b5ba0) at
/home/vagrant/src-OPAL-2.4.0/src/Track/TrackRun.cpp:353
#10 0x00005555560aa482 in TrackRun::execute (this=0x5555585b5ba0) at
/home/vagrant/src-OPAL-2.4.0/src/Track/TrackRun.cpp:174
#11 0x0000555555f3a46f in OpalParser::execute (this=<optimized out>,
object=0x5555585b5ba0, name="RUN") at
/home/vagrant/src-OPAL-2.4.0/src/OpalParser/OpalParser.cpp:139
#12 0x0000555555f3e054 in OpalParser::parseAction (this=0x5555585b2870,
stat=...) at /home/vagrant/src-OPAL-2.4.0/src/OpalParser/OpalParser.cpp:172
#13 0x0000555555f3e6a4 in OpalParser::parse (this=0x5555585b2870, stat=...)
at /home/vagrant/src-OPAL-2.4.0/src/OpalParser/OpalParser.cpp:90
#14 0x0000555555f3e42e in OpalParser::run (this=0x5555585b2870) at
/home/vagrant/src-OPAL-2.4.0/src/OpalParser/OpalParser.cpp:607
#15 0x00005555560a25b0 in TrackCmd::execute (this=<optimized out>) at
/home/vagrant/src-OPAL-2.4.0/src/Track/TrackCmd.cpp:211
#16 0x0000555555f3a46f in OpalParser::execute (this=<optimized out>,
object=0x5555585b2050, name="TRACK") at
/home/vagrant/src-OPAL-2.4.0/src/OpalParser/OpalParser.cpp:139
#17 0x0000555555f3b3b0 in OpalParser::parseDefine (this=0x7fffffffd850,
stat=...) at /home/vagrant/src-OPAL-2.4.0/src/OpalParser/OpalParser.cpp:356
#18 0x0000555555f3e65c in OpalParser::parse (this=0x7fffffffd850, stat=...)
at /home/vagrant/src-OPAL-2.4.0/src/OpalParser/OpalParser.cpp:82
#19 0x0000555555f3e42e in OpalParser::run (this=0x7fffffffd850) at
/home/vagrant/src-OPAL-2.4.0/src/OpalParser/OpalParser.cpp:607
#20 0x0000555555f3a9f8 in OpalParser::run (this=0x7fffffffd850,
is=<optimized out>) at
/home/vagrant/src-OPAL-2.4.0/src/OpalParser/OpalParser.cpp:632
#21 0x0000555555e6e4b7 in main (argc=<optimized out>, argv=<optimized out>)
at /home/vagrant/src-OPAL-2.4.0/src/Main.cpp:349
Edited by kraus