Bug 1358510

Summary: lto1: internal compiler error: Segmentation fault
Product: [Fedora] Fedora Reporter: Gene Hightower <gene>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 26CC: alciregi, antonio.montagnani, bugzilla, davejohansen, faxguy, ianuj3, jakub, jwakely, law, leandrobnsilva, makruiten, mk, mpolacek, SpikeFedora
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-05-29 11:52:08 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Gene Hightower 2016-07-20 21:12:24 UTC
Description of problem:

lto1: internal compiler error: Segmentation fault

Version-Release number of selected component (if applicable):

$ gcc --version
gcc (GCC) 6.1.1 20160621 (Red Hat 6.1.1-3)
Copyright (C) 2016 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.

How reproducible:

$ g++ -shared -o libxxxxxxxxxxxx.so Application.o ApplicationAttributes.o AttributedString.o Document.o DocumentState.o DocumentState_breakdown_save.o DocumentState_check.o DocumentState_copy.o DocumentState_fdx_load.o DocumentState_import.o DocumentState_load.o DocumentState_paste.o DocumentState_pdf.o DocumentState_rtf.o DocumentState_scw_load.o DocumentState_scw_save.o EditCtx.o EditFnx.o Element.o Font.o Formation.o Import.o Import_docx.o Layout.o ListParser.o Logging.o Numberer.o Page.o Tracer.o Versioning.o Zip.o backtrace.o boundary_utils.o file_utils.o fonts_conf.o lang_utils.o locale.o process.o server.o shim-application.o shim-application-attributes.o shim-edit_context.o shim_utils.o system_utils.o unicode.o win_utils.o -g -Wl,-rpath=. -L/usr/lib/jvm/java-1.8.0-openjdk/jre/lib/amd64/server -Wl,-rpath,/usr/lib/jvm/java-1.8.0-openjdk/jre/lib/amd64/server -flto -lpangocairo-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lcairo -lpcre -lcurl -lssl -lcrypto -lzip -lz -licui18n -licuuc -licudata   -lboost_filesystem -lboost_iostreams -lboost_locale -lboost_program_options -lboost_system -lboost_timer -ljvm
/usr/include/boost/filesystem/operations.hpp:171:8: note: type ‘file_type’ itself violate the C++ One Definition Rule
   enum file_type
        ^
/usr/include/boost/filesystem/operations.hpp:255:31: note: type ‘struct file_status’ itself violate the C++ One Definition Rule
   class BOOST_FILESYSTEM_DECL file_status
                               ^
/usr/include/boost/filesystem/operations.hpp:744:29: note: type ‘struct directory_entry’ itself violate the C++ One Definition Rule
 class BOOST_FILESYSTEM_DECL directory_entry
                             ^
/usr/include/boost/smart_ptr/shared_ptr.hpp:336:25: note: type ‘struct shared_ptr’ itself violate the C++ One Definition Rule
 template<class T> class shared_ptr
                         ^
/usr/include/boost/filesystem/operations.hpp:890:9: note: type ‘struct directory_iterator’ itself violate the C++ One Definition Rule
   class directory_iterator
         ^
/usr/include/boost/filesystem/operations.hpp:851:10: note: type ‘struct dir_itr_imp’ itself violate the C++ One Definition Rule
   struct dir_itr_imp
          ^
lto1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
lto-wrapper: fatal error: g++ returned 1 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
MKUltra/rules:166: recipe for target 'libscreenwriter.so' failed
make: *** [libscreenwriter.so] Error 1

$ gcc --version
gcc (GCC) 6.1.1 20160621 (Red Hat 6.1.1-3)
Copyright (C) 2016 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.

find my object files at:

<https://digilicious.com/all-o.tar.xz>

Steps to Reproduce:
1. install *-devel packages for libraries on the link line
(boost, pango, cairo, curl, ssl, etc.)
2. download and unpack object files (from digilicious URL above)
3. enter link command

Actual results:

for me it crashed

Expected results:

generate awesomely optimized shared library

Additional info:

Comment 1 Fedora End Of Life 2017-07-25 21:56:39 UTC
This message is a reminder that Fedora 24 is nearing its end of life.
Approximately 2 (two) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 24. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '24'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 24 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 2 Gene Hightower 2017-07-25 23:46:48 UTC
Same issue with new version of Fedora.

$ gcc --version
gcc (GCC) 7.1.1 20170622 (Red Hat 7.1.1-3)
Copyright (C) 2017 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.

$ make -f libs.mk 
g++ -shared -o libscreenwriter.so Application.o ApplicationAttributes.o AttributedString.o Document.o DocumentState.o DocumentState_breakdown_save.o DocumentState_check.o DocumentState_copy.o DocumentState_fdx_load.o DocumentState_import.o DocumentState_load.o DocumentState_paste.o DocumentState_pdf.o DocumentState_rtf.o DocumentState_scw_load.o DocumentState_scw_save.o DocumentState_utils.o EditCtx.o EditFnx.o Element.o Font.o Formation.o Import.o Import_docx.o Layout.o ListParser.o Logging.o Numberer.o Page.o Tracer.o Versioning.o Zip.o backtrace.o boundary_utils.o file_utils.o fonts_conf.o lang_utils.o locale.o process.o shim-application.o shim-application-attributes.o shim-edit_context.o shim_utils.o split.o system_utils.o uid.o unicode.o win_utils.o -Wl,-rpath=. -lpthread -lrt -L/usr/lib/jvm/java-1.8.0-openjdk/jre/lib/amd64/server -Wl,-rpath,/usr/lib/jvm/java-1.8.0-openjdk/jre/lib/amd64/server -flto -lpangocairo-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lcairo -lpcre -lcurl -lssl -lcrypto -lzip -lz -licui18n -licuuc -licudata    -lboost_filesystem -lboost_iostreams -lboost_locale -lboost_program_options -lboost_system -lboost_timer -lboost_filesystem -lboost_iostreams -lboost_locale -lboost_program_options -lboost_system -lboost_timer -ljvm
/usr/include/boost/filesystem/operations.hpp:171:8: note: type ‘file_type’ itself violate the C++ One Definition Rule
   enum file_type
        ^
/usr/include/boost/filesystem/operations.hpp:255:31: note: type ‘struct file_status’ itself violate the C++ One Definition Rule
   class BOOST_FILESYSTEM_DECL file_status
                               ^
/usr/include/boost/filesystem/operations.hpp:744:29: note: type ‘struct directory_entry’ itself violate the C++ One Definition Rule
 class BOOST_FILESYSTEM_DECL directory_entry
                             ^
/usr/include/boost/smart_ptr/shared_ptr.hpp:336:25: note: type ‘struct shared_ptr’ itself violate the C++ One Definition Rule
 template<class T> class shared_ptr
                         ^
/usr/include/c++/7/bits/stl_vector.h:79:9: note: type ‘struct directory_iterator *’ should match type ‘struct directory_iterator *’
         pointer;
         ^
/usr/include/c++/7/bits/stl_vector.h:81:14: note: type ‘struct _Vector_impl’ itself violate the C++ One Definition Rule
       struct _Vector_impl
              ^
/usr/include/c++/7/bits/stl_vector.h:216:11: note: type ‘struct vector’ itself violate the C++ One Definition Rule
     class vector : protected _Vector_base<_Tp, _Alloc>
           ^
/usr/include/c++/7/bits/stl_stack.h:99:11: note: type ‘struct stack’ itself violate the C++ One Definition Rule
     class stack
           ^
/usr/include/boost/filesystem/operations.hpp:1005:12: note: type ‘struct recur_dir_itr_imp’ itself violate the C++ One Definition Rule
     struct recur_dir_itr_imp
            ^
/usr/include/boost/filesystem/operations.hpp:851:10: note: type ‘struct dir_itr_imp’ itself violate the C++ One Definition Rule
   struct dir_itr_imp
          ^
lto1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
lto-wrapper: fatal error: g++ returned 1 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make: *** [MKUltra/rules:222: libscreenwriter.so] Error 1

Comment 3 Alessio 2017-10-25 23:13:03 UTC
Similar problem compiling an Arduino sketch. If serial entries are in the sketch (like Serial.begin(9600);) I have this error. Without serial directives, the sketch works fine.

lto1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://bugzilla.redhat.com/> for instructions.
lto-wrapper: fatal error: /usr/bin/avr-gcc returned 1 exit status
compilation terminated.
/usr/lib/gcc/avr/6.3.0/../../../../avr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Uno.

Comment 4 Gene Hightower 2017-10-26 04:52:39 UTC
Same problem with new compiler.

$ gcc --version
gcc (GCC) 7.2.1 20170915 (Red Hat 7.2.1-2)
Copyright (C) 2017 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.

lto1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
lto-wrapper: fatal error: g++ returned 1 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status

Comment 5 Gene Hightower 2017-10-26 04:53:10 UTC
Without -flto option everything compiles and links just fine.

Comment 6 Martijn Kruiten 2017-10-26 13:22:17 UTC
Same error here when compiling for Arduino on up to date Fedora 27 (same error messages as Alessio, https://bugzilla.redhat.com/show_bug.cgi?id=1358510#c3). Not sure if I can get the Arduino IDE to compile without the -flto flag.

Comment 7 Alessio 2017-10-27 04:21:45 UTC
(In reply to Martijn Kruiten from comment #6)
> Same error here when compiling for Arduino on up to date Fedora 27 (same
> error messages as Alessio,
> https://bugzilla.redhat.com/show_bug.cgi?id=1358510#c3). Not sure if I can
> get the Arduino IDE to compile without the -flto flag.

In the Arduino IDE, if in "Board Manageg" I install Arduino AVR Boards version 1.6.19 (downgrade from the default 1.6.20), the sketch is compiled without errors.

Using instead the default 1.6.20, and adding "-fno-devirtualize" to compiler.cpp.flags in /usr/share/arduino/hardware/arduino/avr/platform.txt, the sketch is compiled without errors.

Again, using the default 1.6.20 and removing "-flto" from compiler.cpp.flags in the default /usr/share/arduino/hardware/arduino/avr/platform.txt file (I mean without adding "-fno-devirtualize", the sketch is compiled without errors as well.

I don't spot any difference between platform.txt from 1.6.20 and 1.6.19

Comment 8 MK 2017-11-30 18:20:46 UTC
In Fedora 27 using current stock avr-gcc 6.3.0 this is reproducible as per comment 3 (any Arduino sketch invoking Serial), and as per comment 7 adding the "-fno-devirtualize" flag in avr/platform.txt solves the problem (thanks for that).

There's an upstream report https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81612
which claims it is a GCC bug corrected in 6.4.

Comment 9 Leandro Boari Naves Silva 2017-12-04 17:03:46 UTC
(In reply to MK from comment #8)
> In Fedora 27 using current stock avr-gcc 6.3.0 this is reproducible as per
> comment 3 (any Arduino sketch invoking Serial), and as per comment 7 adding
> the "-fno-devirtualize" flag in avr/platform.txt solves the problem (thanks
> for that).
> 
> There's an upstream report https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81612
> which claims it is a GCC bug corrected in 6.4.

This doesn't works for me. I tried add "-fno-devirtualize" here:

"compiler.c.flags=-c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects -fno-devirtualize"

I'm right?

Thank you!

Comment 10 MK 2017-12-05 09:56:29 UTC
(In reply to Leandro Boari Naves Silva from comment #9)

> This doesn't works for me. I tried add "-fno-devirtualize" here:
> 
> "compiler.c.flags=-c -g -Os {compiler.warning_flags} -std=gnu11

No, those are the C flags.  You want compiler.cpp.flags instead.

Comment 11 Erik Johnson 2017-12-21 16:06:18 UTC
Thanks, this worked for me - same scenario all around "Serial" library used in avr-gcc

Comment 12 antonio montagnani 2018-01-20 22:50:44 UTC
(In reply to Alessio from comment #7)
> (In reply to Martijn Kruiten from comment #6)
> > Same error here when compiling for Arduino on up to date Fedora 27 (same
> > error messages as Alessio,
> > https://bugzilla.redhat.com/show_bug.cgi?id=1358510#c3). Not sure if I can
> > get the Arduino IDE to compile without the -flto flag.
> 
> In the Arduino IDE, if in "Board Manageg" I install Arduino AVR Boards
> version 1.6.19 (downgrade from the default 1.6.20), the sketch is compiled
> without errors.
> 
> Using instead the default 1.6.20, and adding "-fno-devirtualize" to
> compiler.cpp.flags in /usr/share/arduino/hardware/arduino/avr/platform.txt,
> the sketch is compiled without errors.
> 
> Again, using the default 1.6.20 and removing "-flto" from compiler.cpp.flags
> in the default /usr/share/arduino/hardware/arduino/avr/platform.txt file (I
> mean without adding "-fno-devirtualize", the sketch is compiled without
> errors as well.
> 
> I don't spot any difference between platform.txt from 1.6.20 and 1.6.19

I do not have any -flto option in platform.txt file...is it correct??

# ctags
# ------------------------------
tools.ctags.path=/usr/bin
tools.ctags.cmd.path={path}/arduino-ctags
tools.ctags.pattern="{cmd.path}" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "{source_file}"

# additional entries
tools.avrdude.path=/usr/bin

preproc.macros.flags=-w -x c++ -E -CC
#preproc.macros.compatibility_flags={build.mbed_api_include} {build.nRF51822_api_include} {build.ble_api_include} {compiler.libsam.c.flags} {compiler.arm.cmsis.path} {build.variant_system_include}
#recipe.preproc.macros="{compiler.path}{compiler.cpp.cmd}" {compiler.cpreprocessor.flags} {compiler.cpp.flags} {preproc.macros.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {preproc.macros.compatibility_flags} {includes} "{source_file}" -o "{preprocessed_file_path}"

Comment 13 Lee Howard 2018-01-27 20:32:46 UTC
As in comment 7, I resolved this problem on Fedora 27 by adding "-fno-devirtualize" to the end of the compiler.cpp.flags line in /usr/share/arduino/hardware/arduino/avr/platform.txt

Thanks

Comment 14 Anuj Jain 2018-02-04 18:26:21 UTC
(In reply to Alessio from comment #7)
> (In reply to Martijn Kruiten from comment #6)
> > Same error here when compiling for Arduino on up to date Fedora 27 (same
> > error messages as Alessio,
> > https://bugzilla.redhat.com/show_bug.cgi?id=1358510#c3). Not sure if I can
> > get the Arduino IDE to compile without the -flto flag.
> 
> In the Arduino IDE, if in "Board Manageg" I install Arduino AVR Boards
> version 1.6.19 (downgrade from the default 1.6.20), the sketch is compiled
> without errors.
> 
> Using instead the default 1.6.20, and adding "-fno-devirtualize" to
> compiler.cpp.flags in /usr/share/arduino/hardware/arduino/avr/platform.txt,
> the sketch is compiled without errors.
> 
> Again, using the default 1.6.20 and removing "-flto" from compiler.cpp.flags
> in the default /usr/share/arduino/hardware/arduino/avr/platform.txt file (I
> mean without adding "-fno-devirtualize", the sketch is compiled without
> errors as well.
> 
> I don't spot any difference between platform.txt from 1.6.20 and 1.6.19

It worked properly for me; thanks a lot for this, but can you please explain little-bit.

Comment 15 Alessio 2018-02-04 22:19:49 UTC
However, there is an avr-gcc version on updates-testing that seems to solve the Arduino problem.
https://bodhi.fedoraproject.org/updates/FEDORA-2018-32c7201e73

Comment 16 Fedora End Of Life 2018-05-03 08:38:35 UTC
This message is a reminder that Fedora 26 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 26. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '26'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 26 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 17 Fedora End Of Life 2018-05-29 11:52:08 UTC
Fedora 26 changed to end-of-life (EOL) status on 2018-05-29. Fedora 26
is no longer maintained, which means that it will not receive any
further security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.