Segmentation fault in tests on fedora 36 with gfortran-12 and -flto=auto
The original report is here https://bugzilla.redhat.com/show_bug.cgi?id=2046933
Fedora defines a set of compilation and link options for the packages to follow https://docs.fedoraproject.org/en-US/packaging-guidelines/RPMMacros/#_macros_providing_compiler_and_linker_flags
One of these options is -flto=auto
and it appears to be associated with segmentation faults.
Appending -fno-lto
to the set of options avoids the segmentation faults.
This issue includes a Dockerfile that can be used to reproduce the problem.
The details of the setup:
- qe version https://github.com/QEF/q-e/archive/refs/tags/qe-7.0.tar.gz
- psp fetched using
cd test-suite && make pseudo
The compilation and run are performed on fedora 36 x86_64, and use
rpm -q gcc-gfortran
gcc-gfortran-12.0.1-0.3.fc36.x86_64
The problem can be reproduced with the following Dockerfile
FROM fedora:36@sha256:dfb26a5dbc30de897f86e60870a4b4000c7733545e866fd1c03637a931b2d4e3
# Install packaging tools
RUN dnf install -y \
git fedpkg fedora-packager curl
# Install build dependencies
RUN dnf install -y \
make gcc-gfortran \
openssh-clients which
RUN mkdir -p /root/espresso/pseudo/ \
&& curl -Lo /root/espresso/pseudo/Si.pz-vbc.UPF http://nninc.cnf.cornell.edu/psp_files/Si.pz-vbc.UPF
CMD ["/bin/bash"]
Build the image and enter the container
docker build -t qe:latest .
docker run -it --rm --name qe qe:latest
Compile and run tests
mkdir /qe && cd /qe
curl -LO https://github.com/QEF/q-e/archive/refs/tags/qe-7.0.tar.gz
tar zxf qe-7.0.tar.gz && cd q-e-qe-7.0
# Allow passing of flags to external utils like fox or devicexlib
sed -i 's|FOX_FLAGS = @foxflags@|FOX_FLAGS = $(FOXFLAGS)|' install/make.inc.in
export FLAGS='-fallow-argument-mismatch -O2 -flto=auto'
make clean || true
export FCFLAGS=$FLAGS && export CFLAGS=$FLAGS && export FFLAGS=$FLAGS && export FOXFLAGS="$FLAGS -fPIE -x f95-cpp-input"
./configure && make all
cd test-suite/pw_pbe/
../../bin/pw.x < pbe0-si111.in
Result
Program PWSCF v.7.0 starts on 30Jan2022 at 11:46:15
This program is part of the open-source Quantum ESPRESSO suite
for quantum simulation of materials; please cite
"P. Giannozzi et al., J. Phys.:Condens. Matter 21 395502 (2009);
"P. Giannozzi et al., J. Phys.:Condens. Matter 29 465901 (2017);
"P. Giannozzi et al., J. Chem. Phys. 152 154105 (2020);
URL http://www.quantum-espresso.org",
in publications or presentations arising from this work. More details at
http://www.quantum-espresso.org/quote
Serial version
2145 MiB available memory on the printing compute node when the environment starts
Waiting for input...
Reading input from standard input
Current dimensions of program PWSCF are:
Max number of different atomic species (ntypx) = 10
Max number of k-points (npk) = 40000
Max angular momentum in pseudopotentials (lmaxx) = 4
IMPORTANT: XC functional enforced from input :
Exchange-correlation= PBE0
( 6 4 8 4 0 0 0)
EXX-fraction = 0.25
Any further DFT definition will be discarded
Please, verify this is what you really want
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
#0 0x7f8bf7de0a32 in ???
#1 0x7f8bf7ddfbc5 in ???
#2 0x7f8bf7ab7adf in ???
#3 0x802e22 in ???
at ../../Modules/qes_init_module.f90:2340
#4 0x805b99 in pw_init_qexsd_input_.constprop.0
at /qe/q-e-qe-7.0/PW/src/pw_init_qexsd_input.f90:475
#5 0x453f6d in iosys_
at /qe/q-e-qe-7.0/PW/src/input.f90:1729
#6 0x4a020d in run_pwscf_
at /qe/q-e-qe-7.0/PW/src/run_pwscf.f90:102
#7 0x4043a9 in pwscf
at /qe/q-e-qe-7.0/PW/src/pwscf.f90:85
#8 0x40396c in main
at /qe/q-e-qe-7.0/PW/src/pwscf.f90:40
Segmentation fault (core dumped)
ldd ../../bin/pw.x
linux-vdso.so.1 (0x00007fff12faa000)
libgfortran.so.5 => /lib64/libgfortran.so.5 (0x00007f6f7f1b1000)
libm.so.6 => /lib64/libm.so.6 (0x00007f6f7f0d3000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f6f7f0b3000)
libquadmath.so.0 => /lib64/libquadmath.so.0 (0x00007f6f7f06b000)
libc.so.6 => /lib64/libc.so.6 (0x00007f6f7ee69000)
/lib64/ld-linux-x86-64.so.2 (0x00007f6f7f47d000)