Bug 82985 - [7 Regression] ICC: in vn_nary_build_or_lookup_1, at tree-ssa-sccvn.c:1722
Summary: [7 Regression] ICC: in vn_nary_build_or_lookup_1, at tree-ssa-sccvn.c:1722
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 7.2.1
: P3 normal
Target Milestone: 7.3
Assignee: Richard Biener
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-14 09:14 UTC by BlenderEi
Modified: 2017-11-15 20:04 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work: 6.4.1, 8.0
Known to fail: 7.2.1
Last reconfirmed: 2017-11-14 00:00:00


Attachments
Screenshot of the compilation process and the crash of GCC (104.77 KB, image/jpeg)
2017-11-14 09:14 UTC, BlenderEi
Details
This is an archive containing the preprocessed File that triggered the Bug (FullSystemOptimize.ii) as well as my console history, because after I added CMAKE_CXX_FLAGS "-save-temps" it compiles?!?! (773.08 KB, application/zip)
2017-11-14 14:58 UTC, BlenderEi
Details
This is the verbose output with the CMAKE flag 'set (CMAKE_CXX_FLAGS "-v --save-temps")' (8.25 KB, application/zip)
2017-11-14 16:40 UTC, BlenderEi
Details
Output of command "make VERBOSE=1" with altered makefile with additional flags which invokes the compiler to crash (2.53 KB, application/zip)
2017-11-14 17:13 UTC, BlenderEi
Details
FullSystemOptimize.ii and FullSystemOptimize.s files - those are the only ones I got from the last command (969.28 KB, application/zip)
2017-11-14 17:57 UTC, BlenderEi
Details
somewhat reduced testcase (3.82 KB, text/plain)
2017-11-14 20:28 UTC, Markus Trippelsdorf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description BlenderEi 2017-11-14 09:14:28 UTC
Created attachment 42598 [details]
Screenshot of the compilation process and the crash of GCC

Hello, this is my first time reporting a bug, so please be patient ;)

I came across this bug when trying to compile the Direct Sparse Odometry project for my master thesis (see screenshot). You can find it here:
https://github.com/JakobEngel/dso

The steps to reproduce the bug are (on Linux, type in console [why am I even telling you that... ;) ]):

> git clone https://github.com/JakobEngel/dso.git
> sudo apt-get install libsuitesparse-dev libeigen3-dev libboost-all-dev
> cd dso
> mkdir build
> cd build
> cmake ..
> make -j

I was advised to isolate the problem using "C-reduce". I try to do that, but you are probably faster given your experience. Hopefully I can add it to this report, after submitting it.

Thank you for your help and great work!
Comment 1 Markus Trippelsdorf 2017-11-14 11:16:33 UTC
Please attach the (compressed) preprocessed file. 
See https://gcc.gnu.org/bugs/ for instructions.
Comment 2 BlenderEi 2017-11-14 14:58:55 UTC
Created attachment 42601 [details]
This is an archive containing the preprocessed File that triggered the Bug (FullSystemOptimize.ii) as well as my console history, because after  I added CMAKE_CXX_FLAGS "-save-temps" it compiles?!?!

Thank you for your fast reply.
Ok, I have no experience if this is correct, but what I did was:

Added this line to the CMakeLists.txt in the main directory "/dso":
set (CMAKE_CXX_FLAGS "-save-temps")

And with this, it actually compiled the code!!! o.O
But it definitely didnt work before. To prove that, I attached my console history as well. You can see, that in the beginning the make-command failed. After I changed the file, the compilation succeeded!

Naturally, now I am even more confused. Could you tell me if I missed a step? I checked the instruction website you referred me to, but it didnt tell me how to do this with cmake. So I googled and did my best. Maybe I did a mistake (although, I don't think so).

If you need anything, please just let me know. Thanks a lot for your help!
Comment 3 Markus Trippelsdorf 2017-11-14 15:09:05 UTC
Normally, you could enable verbose output with something like "make VERBOSE=1".
And then add --save-temps to the failing gcc invocation by hand
(and also post the full invocation here).

Thanks. I can reproduce the issue with trunk:

 % g++ -O3 -c FullSystemOptimize.ii
In file included from /usr/include/boost/smart_ptr/enable_shared_from_this.hpp:16:0,
                 from /usr/include/boost/enable_shared_from_this.hpp:16,
                 from /usr/include/boost/thread/pthread/thread_data.hpp:17,
                 from /usr/include/boost/thread/thread_only.hpp:17,
                 from /usr/include/boost/thread/thread.hpp:12,
                 from /usr/include/boost/thread.hpp:13,
                 from /home/akp/dso/src/util/IndexThreadReduce.h:28,
                 from /home/akp/dso/src/FullSystem/FullSystem.h:39,
                 from /home/akp/dso/src/FullSystem/FullSystemOptimize.cpp:26:
/usr/include/boost/smart_ptr/weak_ptr.hpp: In constructor ‘boost::weak_ptr<T>::weak_ptr(boost::weak_ptr<T>&&)’:
/usr/include/boost/smart_ptr/weak_ptr.hpp:109:82: internal compiler error: tree check: expected tree that contains ‘decl common’ structure, have ‘identifier_node’ in get_inner_reference, at expr.c:7003
     weak_ptr( weak_ptr && r )
                                                                                  ^
0x6adc65 tree_contains_struct_check_failed(tree_node const*, tree_node_structure_enum, char const*, int, char const*)
        /home/markus/gcc/gcc/tree.c:9268
0xb67738 contains_struct_check(tree_node*, tree_node_structure_enum, char const*, int, char const*)
        /home/markus/gcc/gcc/tree.h:3202
0xb67738 get_inner_reference(tree_node*, long*, long*, tree_node**, machine_mode*, int*, int*, int*)
        /home/markus/gcc/gcc/expr.c:7003
0xbaed4b fold_unary_loc(unsigned int, tree_code, tree_node*, tree_node*)
        /home/markus/gcc/gcc/fold-const.c:7695
0xbb0189 fold_build1_loc(unsigned int, tree_code, tree_node*, tree_node*)
        /home/markus/gcc/gcc/fold-const.c:12068
0x788a6c cp_fold_convert(tree_node*, tree_node*)
        /home/markus/gcc/gcc/cp/cvt.c:607
0x966275 build_static_cast_1
        /home/markus/gcc/gcc/cp/typeck.c:6856
0x9669b4 build_static_cast(tree_node*, tree_node*, int)
        /home/markus/gcc/gcc/cp/typeck.c:7078
0x87a55e cp_parser_postfix_expression
        /home/markus/gcc/gcc/cp/parser.c:6696
0x87d08a cp_parser_unary_expression
        /home/markus/gcc/gcc/cp/parser.c:8363
0x85a186 cp_parser_cast_expression
        /home/markus/gcc/gcc/cp/parser.c:9131
0x85a9f7 cp_parser_binary_expression
        /home/markus/gcc/gcc/cp/parser.c:9232
0x85c3d4 cp_parser_assignment_expression
        /home/markus/gcc/gcc/cp/parser.c:9519
0x85e7f6 cp_parser_parenthesized_expression_list
        /home/markus/gcc/gcc/cp/parser.c:7822
0x880e90 cp_parser_mem_initializer
        /home/markus/gcc/gcc/cp/parser.c:14548
0x880e90 cp_parser_mem_initializer_list
        /home/markus/gcc/gcc/cp/parser.c:14434
0x880e90 cp_parser_ctor_initializer_opt
        /home/markus/gcc/gcc/cp/parser.c:14405
0x880e90 cp_parser_ctor_initializer_opt_and_function_body
        /home/markus/gcc/gcc/cp/parser.c:21859
0x883866 cp_parser_function_definition_after_declarator
        /home/markus/gcc/gcc/cp/parser.c:26765
0x884abc cp_parser_late_parsing_for_member
        /home/markus/gcc/gcc/cp/parser.c:27645

I will try to reduced it.
Comment 4 Markus Trippelsdorf 2017-11-14 15:14:58 UTC
(In reply to Markus Trippelsdorf from comment #3)
> Normally, you could enable verbose output with something like "make
> VERBOSE=1".
> And then add --save-temps to the failing gcc invocation by hand
> (and also post the full invocation here).
> 
> Thanks. I can reproduce the issue with trunk:

Nope, that issue was already fixed yesterday: PR82360.
Comment 5 BlenderEi 2017-11-14 15:38:22 UTC
Wow, ok nice. So my issue is solved?

This would be amazing. Thank you for your help in that case.

I will leave the status as is, because I am not the one that should decide about the status with my little experience.

Have a great week, in case we are finished here. Kind regards!
Comment 6 Markus Trippelsdorf 2017-11-14 15:44:45 UTC
(In reply to BlenderEi from comment #5)
> Wow, ok nice. So my issue is solved?
> 
> This would be amazing. Thank you for your help in that case.
> 
> I will leave the status as is, because I am not the one that should decide
> about the status with my little experience.
> 
> Have a great week, in case we are finished here. Kind regards!

No, sorry for the misunderstanding.
The issue that I was seeing was a gcc-8 only regression.
It has nothing to do with your issue. So we are back to square one.

Please post the full gcc invocation and output with -v --save-temps.
Comment 7 BlenderEi 2017-11-14 16:40:59 UTC
Created attachment 42603 [details]
This is the verbose output with the CMAKE flag 'set (CMAKE_CXX_FLAGS "-v --save-temps")'

Ok, in that case I hope I understood what you need. See the attached archive.

Typing "make -VERBOSE=1" didn't achieve anything but displaying the help text. Therefore, again I tried the CMAKE variant.

Note: My gcc version is a little different I noticed, but I was confirmed that 7.2.1 is affected by this bug too.

Please tell me if you need something else.
Comment 8 Markus Trippelsdorf 2017-11-14 16:49:32 UTC
OK. I need:

> git clone https://github.com/JakobEngel/dso.git
> sudo apt-get install libsuitesparse-dev libeigen3-dev libboost-all-dev
> cd dso
> mkdir build
> cd build
> cmake ..
> make VERBOSE=1

Then add -v --save-temps to the gcc invocation that hits the internal compiler error.
And then please paste the full output of that invocation here.
Comment 9 BlenderEi 2017-11-14 17:13:16 UTC
Created attachment 42604 [details]
Output of command "make VERBOSE=1" with altered makefile with additional flags which invokes the compiler to crash

Oh ok. Sorry for this taking so long. If I didnt misunderstand you, I got it now.

I have now executed:
> make VERBOSE=1
after I changed the Makefile (generated by CMake) by adding the flags (-v --save-temps) inbetween "/usr/bin/c++  $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS)" and "-o CMakeFiles/dso.dir/src/FullSystem/FullSystemOptimize.cpp.o -c /home/akp/dso/src/FullSystem/FullSystemOptimize.cpp" (because building the "FullSystemOptimize" object seems to be the reason for the crash).

What do you say, is this useful?
Comment 10 Ahmad Fatoum 2017-11-14 17:24:02 UTC
(In reply to BlenderEi from comment #9) 
> What do you say, is this useful?

Hi Adam,

--save-temps saves some temporary files (
Comment 11 Ahmad Fatoum 2017-11-14 17:25:36 UTC
(In reply to Ahmad Fatoum from comment #10)
> (In reply to BlenderEi from comment #9) 
> > What do you say, is this useful?
> 
> Hi Adam,
> 
> --save-temps saves some temporary files (

*.i, *.s, *.o) which might be useful as well.
Comment 12 Markus Trippelsdorf 2017-11-14 17:42:38 UTC
(In reply to BlenderEi from comment #9)
> Created attachment 42604 [details]
> Output of command "make VERBOSE=1" with altered makefile with additional
> flags which invokes the compiler to crash
> 
> Oh ok. Sorry for this taking so long. If I didnt misunderstand you, I got it
> now.
> 
> I have now executed:
> > make VERBOSE=1
> after I changed the Makefile (generated by CMake) by adding the flags (-v
> --save-temps) inbetween "/usr/bin/c++  $(CXX_DEFINES) $(CXX_INCLUDES)
> $(CXX_FLAGS)" and "-o
> CMakeFiles/dso.dir/src/FullSystem/FullSystemOptimize.cpp.o -c
> /home/akp/dso/src/FullSystem/FullSystemOptimize.cpp" (because building the
> "FullSystemOptimize" object seems to be the reason for the crash).
> 
> What do you say, is this useful?

Yes, thank you. Can you please attach the FullSystemOptimize.ii file (again)?
Comment 13 BlenderEi 2017-11-14 17:57:37 UTC
Created attachment 42605 [details]
FullSystemOptimize.ii and FullSystemOptimize.s files - those are the only ones I got from the last command

Oh yeah, of course.
I only have the two generated files .ii and .s of one .cpp file. Nothing else is there in the build directory (as opposed to last time, when the compilation was successful).

I have attached them.
Comment 14 Markus Trippelsdorf 2017-11-14 18:02:56 UTC
Thank you. I can reproduce the issue now.
Reducing...
Comment 15 BlenderEi 2017-11-14 18:28:59 UTC
I admire your positivity, Markus ;)

Good luck!
Comment 16 Markus Trippelsdorf 2017-11-14 20:28:30 UTC
Created attachment 42606 [details]
somewhat reduced testcase

(Creduce struggles with 7.6MB boost testcases...)

 % g++ -mavx2 -c -O2 FullSystemOptimize.ii -w
FullSystemOptimize.ii: In member function ‘bool std::FullSystem::doStepFromBackup()’:
FullSystemOptimize.ii:446:6: internal compiler error: in vn_nary_build_or_lookup_1, at tree-ssa-sccvn.c:1722
 bool FullSystem::doStepFromBackup() {
      ^~~~~~~~~~
0xc52643 vn_nary_build_or_lookup_1
        ../../gcc/gcc/tree-ssa-sccvn.c:1722
0xc546a9 vn_nary_build_or_lookup
        ../../gcc/gcc/tree-ssa-sccvn.c:1758
0xc546a9 vn_reference_lookup_3
        ../../gcc/gcc/tree-ssa-sccvn.c:2037
0xbbe6fe walk_non_aliased_vuses(ao_ref*, tree_node*, void* (*)(ao_ref*, tree_node*, unsigned int, void*), void* (*)(ao_ref*, tree_node*, void*, bool*), tree_node* (*)(tree_node*), void*)
        ../../gcc/gcc/tree-ssa-alias.c:2872
0xc53179 vn_reference_lookup(tree_node*, tree_node*, vn_lookup_kind, vn_reference_s**, bool)
        ../../gcc/gcc/tree-ssa-sccvn.c:2450
0xc558e0 visit_reference_op_load
        ../../gcc/gcc/tree-ssa-sccvn.c:3691
0xc558e0 visit_use
        ../../gcc/gcc/tree-ssa-sccvn.c:4031
0xc57050 process_scc
        ../../gcc/gcc/tree-ssa-sccvn.c:4293
0xc57050 extract_and_process_scc_for_name
        ../../gcc/gcc/tree-ssa-sccvn.c:4349
0xc57050 DFS
        ../../gcc/gcc/tree-ssa-sccvn.c:4401
0xc58496 sccvn_dom_walker::before_dom_children(basic_block_def*)
        ../../gcc/gcc/tree-ssa-sccvn.c:4854
0x10ea63a dom_walker::walk(basic_block_def*)
        ../../gcc/gcc/domwalk.c:265
0xc5905a run_scc_vn(vn_lookup_kind)
        ../../gcc/gcc/tree-ssa-sccvn.c:4978
0xc356df execute
        ../../gcc/gcc/tree-ssa-pre.c:5093
Comment 17 Richard Biener 2017-11-15 10:33:49 UTC
Looks like a dup of PR81790.  Will backport the fix.
Comment 18 Richard Biener 2017-11-15 12:51:11 UTC
Author: rguenth
Date: Wed Nov 15 12:50:39 2017
New Revision: 254766

URL: https://gcc.gnu.org/viewcvs?rev=254766&root=gcc&view=rev
Log:
2017-11-15  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/82985
	Backport from mainline
	2017-08-15  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/81790
	* tree-ssa-sccvn.c (vn_lookup_simplify_result): Handle both
	CONSTRUCTORs from simplifying and VN.

	* gcc.dg/torture/pr81790.c: New testcase.
	* g++.dg/torture/pr82985.C: Likewise.

Added:
    branches/gcc-7-branch/gcc/testsuite/g++.dg/torture/pr82985.C
    branches/gcc-7-branch/gcc/testsuite/gcc.dg/torture/pr81790.c
Modified:
    branches/gcc-7-branch/gcc/ChangeLog
    branches/gcc-7-branch/gcc/testsuite/ChangeLog
    branches/gcc-7-branch/gcc/tree-ssa-sccvn.c
Comment 19 Richard Biener 2017-11-15 12:53:52 UTC
Author: rguenth
Date: Wed Nov 15 12:53:21 2017
New Revision: 254767

URL: https://gcc.gnu.org/viewcvs?rev=254767&root=gcc&view=rev
Log:
2017-11-15  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/82985
	* g++.dg/torture/pr82985.C: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/torture/pr82985.C
Modified:
    trunk/gcc/testsuite/ChangeLog
Comment 20 Markus Trippelsdorf 2017-11-15 13:02:46 UTC
Fixed. Thanks.
Comment 21 BlenderEi 2017-11-15 20:04:58 UTC
Thank you for your fast actions.
Best regards!