[Bug lto/97290] Segmentation fault in lto-wrapper

2020-10-05 Thread markus.rothe at rite dot cc via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97290

--- Comment #5 from Markus Rothe  ---
The spec file is available here: https://github.com/markus289/aws-sdk-cpp-rpms

But I was also able to reproduce the problem on a Fedora 32 machine without
rpm/mock/etc involved as follows:

[ Note, that this would install some files in ${HOME}/test-error/ when running
'make' as it downloads dependencies and installs them to the prefix (e.g.
aws-c-common). ]

curl -L https://github.com/aws/aws-sdk-cpp/archive/1.8.61.tar.gz|tar xz
cd aws-sdk-cpp-1.8.61 && mkdir build && cd build
CFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches
-pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
-Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
-fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64
-mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection'
export CFLAGS
CXXFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g
-grecord-gcc-switches -pipe -Wall -Werror=format-security
-Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64 -mtune=generic
-fasynchronous-unwind-tables -fstack-clash-protection'
export CXXFLAGS
FFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches
-pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
-Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
-fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64
-mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection
-I/usr/lib64/gfortran/modules'
export FFLAGS
FCFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches
-pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
-Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
-fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64
-mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection
-I/usr/lib64/gfortran/modules'
export FCFLAGS
LDFLAGS='-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld ' 
export LDFLAGS
LT_SYS_LIBRARY_PATH=/usr/lib64:
export LT_SYS_LIBRARY_PATH
CC=gcc
export CC
CXX=g++
export CXX
/usr/bin/cmake ../ -DCMAKE_C_FLAGS_RELEASE:STRING=-DNDEBUG
-DCMAKE_CXX_FLAGS_RELEASE:STRING=-DNDEBUG
-DCMAKE_Fortran_FLAGS_RELEASE:STRING=-DNDEBUG -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
-DCMAKE_INSTALL_PREFIX:PATH=${HOME}/test-error/usr
-DINCLUDE_INSTALL_DIR:PATH=${HOME}/test-error/usr/include
-DLIB_INSTALL_DIR:PATH=${HOME}/test-error/usr/lib64
-DSYSCONF_INSTALL_DIR:PATH=${HOME}/test-error/etc
-DSHARE_INSTALL_PREFIX:PATH=${HOME}/test-error/usr/share -DLIB_SUFFIX=64
-DBUILD_SHARED_LIBS:BOOL=ON -DBUILD_DEPS:BOOL=TRUE
-DAUTORUN_UNIT_TESTS:BOOL=FALSE -DCUSTOM_MEMORY_MANAGEMENT:BOOL=FALSE
-DBUILD_ONLY=ec2
make
[...]
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status

Does this help? I know that the *FLAGS are quite specific to Fedora...

[Bug lto/97290] Segmentation fault in lto-wrapper

2020-10-05 Thread markus.rothe at rite dot cc via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97290

--- Comment #2 from Markus Rothe  ---
I am writing the instructions on how the .o file is produced now.

The instructions to fetch the files are wrong. This is correct:

$ mkdir -p reproduce-tmp/CMakeFiles/aws-cpp-sdk-ec2.dir/
$ cd reproduce-tmp/
$ curl -o CMakeFiles/aws-cpp-sdk-ec2.dir/ub_EC2.cpp.o
https://files.markus289.com/aifoo3/ub_EC2.cpp.o
$ curl -o lm.res https://files.markus289.com/aifoo3/lm.res
$ mv -- lm.res -lm.res
$ tree
.
├── CMakeFiles
│   └── aws-cpp-sdk-ec2.dir
│   └── ub_EC2.cpp.o
└── lm.res

2 directories, 2 files

[Bug lto/97290] New: Segmentation fault in lto-wrapper

2020-10-05 Thread markus.rothe at rite dot cc via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97290

Bug ID: 97290
   Summary: Segmentation fault in lto-wrapper
   Product: gcc
   Version: 10.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: lto
  Assignee: unassigned at gcc dot gnu.org
  Reporter: markus.rothe at rite dot cc
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

Hello, I get a segmentation fault when building RPMs for the AWS SDK for C++ on
Fedora 33. This version of Fedora enables LTO by default, previous versions did
not use LTO by default. So there are several layers that I had to peal apart in
order to come up with what I can show you below. I welcome any suggestions on
how to debug this problem further.

Within the cmake based build process, lto-wrapper is called and it segfaults.

To reproduce, I did the following on a Fedora 33 machine:

[ Warning, ub_EC2.cpp.o is about 700MB large. ]

$ gcc --version
gcc (GCC) 10.2.1 20200826 (Red Hat 10.2.1-3)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ mkdir -p reproduce-tmp/CMakeFiles/aws-cpp-sdk-ec2.dir/
$ cd reproduce-tmp/
$ curl -o CMakeFiles/aws-cpp-sdk-ec2.dir/
https://files.markus289.com/aifoo3/ub_EC2.cpp.o
$ curl -o -lm.res https://files.markus289.com/aifoo3/-lm.res
$ tree
.
├── -lm.res
└── CMakeFiles
└── aws-cpp-sdk-ec2.dir
└── ub_EC2.cpp.o

2 directories, 2 files
$ gdb
[...]
(gdb) set environment COLLECT_GCC=/usr/bin/g++
(gdb) set environment
COMPILER_PATH="/usr/libexec/gcc/x86_64-redhat-linux/10/:/usr/libexec/gcc/x86_64-redhat-linux/10/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/10/:/usr/lib/gcc/x86_64-redhat-linux/:/usr/libexec/gcc/x86_64-redhat-linux/10/:/usr/libexec/gcc/x86_64-redhat-linux/10/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/10/:/usr/lib/gcc/x86_64-redhat-linux/"
(gdb) set environment
LIBRARY_PATH="/usr/lib/gcc/x86_64-redhat-linux/10/../../../../lib64/../lib64/:/lib/../lib64/../lib64/:/usr/lib/../lib64/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/10/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/10/:/usr/lib/gcc/x86_64-redhat-linux/10/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/10/:/usr/lib/gcc/x86_64-redhat-linux/10/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/10/../../../:/lib/:/usr/lib/:/usr/lib/gcc/x86_64-redhat-linux/10/../../../:/lib/:/usr/lib/"
(gdb) set environment COLLECT_GCC_OPTIONS="-c -fno-openmp -fno-openacc -g -O2
-fPIC -O2 -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe
-Werror=format-security -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
-fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64
-mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld -shared -pthread -v -save-temps
-shared-libgcc -march=x86-64 -dumpdir ./ -dumpbase libaws-cpp-sdk-ec2.so.wpa
-fltrans-output-list=libaws-cpp-sdk-ec2.so.ltrans.out -fwpa=12
-fresolution=-lm.res -flinker-output=dyn -shared-libgcc"
(gdb) file /usr/libexec/gcc/x86_64-redhat-linux/10/lto-wrapper
Reading symbols from /usr/libexec/gcc/x86_64-redhat-linux/10/lto-wrapper...
Reading symbols from
/usr/lib/debug/usr/libexec/gcc/x86_64-redhat-linux/10/lto-wrapper-10.2.1-3.fc33.x86_64.debug...
(gdb) set args -fresolution=-lm.res -flinker-output=dyn
CMakeFiles/aws-cpp-sdk-ec2.dir/ub_EC2.cpp.o
(gdb) run
Starting program: /usr/libexec/gcc/x86_64-redhat-linux/10/lto-wrapper
-fresolution=-lm.res -flinker-output=dyn
CMakeFiles/aws-cpp-sdk-ec2.dir/ub_EC2.cpp.o
[Detaching after vfork from child process 109]

Program received signal SIGSEGV, Segmentation fault.
0x0043b314 in simple_object_elf_copy_lto_debug_sections (sobj=0x52b740,
dobj=0x52b7d0, pfn=, err=0x7fffdbf8)
at ../../libiberty/simple-object-elf.c:1515
1515ELF_SET_FIELD (type_functions, ei_class, Sym,
(gdb) bt
#0  0x0043b314 in simple_object_elf_copy_lto_debug_sections
(sobj=0x52b740, dobj=0x52b7d0, pfn=, err=0x7fffdbf8)
at ../../libiberty/simple-object-elf.c:1515
#1  0x00439865 in simple_object_copy_lto_debug_sections (sobj=0x52b740,
dest=0x52b770 "/tmp/ccYbFOK9.debug.temp.o", 
err=0x7fffdbf8, rename=1) at ../../libiberty/simple-object.c:352
#2  0x004562c7 in debug_objcopy (infile=,
rename=rename@entry=true) at ../../gcc/lto-wrapper.c:1127
#3  0x0045857f in run_gcc (argc=, argv=)
at ../../gcc/lto-wrapper.c:1736
#4  0x0043e577 in main (argc=, argv=) at
../../gcc/lto-wrapper.c:1998
(gdb)


The error happens in the following line of code in
libiberty/simple-object-elf.c:1515:

ELF_SET_FIELD (type_functions, ei_class, Sym, ent, st_