Bug 1918957

Summary: GCC Seg Fault
Product: Red Hat Enterprise Linux 7 Reporter: jacob.gannon
Component: gccAssignee: Marek Polacek <mpolacek>
Status: CLOSED WONTFIX QA Contact: Alexandra Petlanová Hájková <ahajkova>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.0CC: fweimer, jacob.gannon, jakub, ohudlick, sipoyare
Target Milestone: rc   
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: 2021-01-21 20:20:53 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:
Embargoed:
Attachments:
Description Flags
Output from compiler
none
error output
none
Godbolt Example none

Description jacob.gannon 2021-01-21 18:39:17 UTC
Created attachment 1749502 [details]
Output from compiler

Description of problem:
GCC has a seg fault when compiling my code.  

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


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 3 Marek Polacek 2021-01-21 20:04:02 UTC
This was fixed in
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=e1e30986f9d8089f1814e56c15caa6c15a65b885
which is a trivial bugfix.  However, it was an ICE-on-invalid problem.  With the fix included,
the attached .ii file emits a deluge of errors, starting with

/opt/osi/12.2/monarch_x86_64/monarch/src/hsh_sdk/include/functional.h:299:139: error: no matching function for call to ‘call_front_binder(hsh::index_sequence_for<std::shared_ptr<IDailyLogQuery> >, void (IDailyLogQuery::*&)(ICassandraQueryFuture*), std::remove_reference<std::tuple<std::shared_ptr<IDailyLogQuery> >&>::type, ICassandraQueryFuture*)’

In RHEL 7.9, we're only fixing critical bugs, and an ICE on invalid code isn't one of them,
therefore I'm inclined to close this bug report.

Comment 4 jacob.gannon 2021-01-21 20:09:56 UTC
I'm fine with closing the bug report, I was expected the seg-fault to be caused by invalid code.  I was just hoping to get better insight into why the code was invalid.  Would you be able to send me the all the errors in the .ii file? 

Thanks

Comment 5 Marek Polacek 2021-01-21 20:19:55 UTC
Created attachment 1749517 [details]
error output

error output log with -std=c++11 and the bugfix above included

Comment 6 Marek Polacek 2021-01-21 20:20:53 UTC
(In reply to jacob.gannon from comment #4)
> I'm fine with closing the bug report, I was expected the seg-fault to be

Thanks for understanding.

> caused by invalid code.  I was just hoping to get better insight into why
> the code was invalid.  Would you be able to send me the all the errors in
> the .ii file? 

Done.

Comment 7 jacob.gannon 2021-01-21 23:11:54 UTC
Created attachment 1749573 [details]
Godbolt Example

I just thought I'd let you know that for GCC 4.8.x this seg faults the compiler, and for GCC 4.9.1 you get the errors that were in your response.  However when I change godbolt to use 4.9.2+ the code compiles fine. 

I'm compiling in std=c++11 mode for each version.  Would you happen to know if the compiler just can't handle the recursive templates in the variant(if I remove the variant code it all works fine).

Comment 8 Marek Polacek 2021-01-22 15:47:00 UTC
I'm not sure; I've tried various revisions of the compiler and found another crash, one that was fixed by 
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=b00f4f15c1d592a3d00c6a1d3bc8d9f01baead36.  After that,
the code seems to compile fine.

I'll note that if you're using RHEL 7, there are much newer versions of GCC available in the Red Hat
Developer Toolset.  For instance, DTS 10 contains GCC 10, which compiles the program just fine (and
supports C++17).

Comment 9 jacob.gannon 2021-01-22 15:48:58 UTC
No worries, thanks for looking into it.  I will try to convince my company to use a newer DTS, I've played with GCC 10 and it is truly an awesome piece of engineering.