https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100494
Bug ID: 100494 Summary: Unterminated recursion in gimple-range.cc (x86_64-w64-mingw32) Product: gcc Version: 11.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: john at thesnappy dot net Target Milestone: --- While using GCC-11.1.0 on x86_64-w64-mingw32 native to build libiberty sha1.c, gimple-range.cc enters what looks like unending recursion: the stack gets over 600 frames deep. Steps to reproduce: 1. Build GCC-11.1.0 for x86_64-w64-mingw32 with default -O2. 2. Attempt to compile binutils-2.36.1/libiberty/sha1.c with -O2 or higher (-O1 does not trigger the issue) gdb.exe --args c:/crossdev/gccmaster/host-toolchain-cross4/bin/../libexec/gcc/x86_64-w64-mingw32/11.1.0/cc1.exe -quiet -v -I . -I C:/crossdev/src/binutils-git-2_36_1/libiberty/../include -iprefix c:\crossdev\gccmaster\host-toolchain-cross4\bin\../lib/gcc/x86_64-w64-mingw32/11.1.0/ -D_REENTRANT -D HAVE_CONFIG_H -D __USE_MINGW_ACCESS -D _GNU_SOURCE C:/crossdev/src/binutils-git-2_36_1/libiberty/sha1.c -quiet -dumpbase sha1.c -dumpbase-ext .c -mtune=generic -march=x86-64 -g -O2 -Wextra -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -Wshadow=local -Wpedantic -version -o C:\msys64\tmp\cc3zpuNw.s GNU gdb (GDB) 10.1 Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-w64-mingw32". Type "show configuration" for configuration details. For bug reporting instructions, please see: <https://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from c:/crossdev/gccmaster/host-toolchain-cross4/bin/../libexec/gcc/x86_64-w64-mingw32/11.1.0/cc1.exe... (gdb) b value-range.cc:1683 Breakpoint 1 at 0x1407b4b70: file ../../../../src/gcc-git-11.1.0/gcc/value-range.cc, line 1683. (gdb) r Starting program: c:\crossdev\gccmaster\host-toolchain-cross4\libexec\gcc\x86_64-w64-mingw32\11.1.0\cc1.exe -quiet -v -I . -I C:/crossdev/src/binutils-git-2_36_1/libiberty/../include -iprefix c:\crossdev\gccmaster\host-toolchain-cross4\bin\../lib/gcc/x86_64-w64-mingw32/11.1.0/ -D_REENTRANT -D HAVE_CONFIG_H -D __USE_MINGW_ACCESS -D _GNU_SOURCE C:/crossdev/src/binutils-git-2_36_1/libiberty/sha1.c -quiet -dumpbase sha1.c -dumpbase-ext .c "-mtune=generic" "-march=x86-64" -g -O2 -Wextra -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes "-Wshadow=local" -Wpedantic -version -o C:\msys64\tmp\cc3zpuNw.s [New Thread 15968.0x5594] [New Thread 15968.0x34f8] [New Thread 15968.0x4304] GNU C17 (GCC) version 11.1.0 (x86_64-w64-mingw32) compiled by GNU C version 10.3.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version none GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "C:/crossdev/prefix-cross2-x86_64-w64-mingw32/lib/gcc/x86_64-w64-mingw32/11.1.0/include" ignoring nonexistent directory "C:/crossdev/prefix-cross2-x86_64-w64-mingw32/include" ignoring nonexistent directory "/crossdev/prefix-cross2-x86_64-w64-mingw32/include" ignoring nonexistent directory "C:/crossdev/prefix-cross2-x86_64-w64-mingw32/lib/gcc/x86_64-w64-mingw32/11.1.0/include-fixed" ignoring nonexistent directory "C:/crossdev/prefix-cross2-x86_64-w64-mingw32/x86_64-w64-mingw32/include" #include "..." search starts here: #include <...> search starts here: . C:/crossdev/src/binutils-git-2_36_1/libiberty/../include c:\crossdev\gccmaster\host-toolchain-cross4\bin\../lib/gcc/x86_64-w64-mingw32/11.1.0/include c:\crossdev\gccmaster\host-toolchain-cross4\bin\../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../include c:\crossdev\gccmaster\host-toolchain-cross4\bin\../lib/gcc/x86_64-w64-mingw32/11.1.0/include-fixed c:\crossdev\gccmaster\host-toolchain-cross4\bin\../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/include /mingw/include End of search list. GNU C17 (GCC) version 11.1.0 (x86_64-w64-mingw32) compiled by GNU C version 10.3.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version none GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: aa2c29976909033911bae4d4392787e2 Thread 1 hit Breakpoint 1, irange::irange_intersect (this=0x5fe500, r=...) at ../../../../src/gcc-git-11.1.0/gcc/value-range.cc:1683 1683 { (gdb) c 179 Will ignore next 178 crossings of breakpoint 1. Continuing. Thread 1 hit Breakpoint 1, irange::irange_intersect (this=0x418360, r=...) at ../../../../src/gcc-git-11.1.0/gcc/value-range.cc:1683 1683 { (gdb) bt #0 ___chkstk_ms () at ../../../../../src/gcc-git-10.3.0/libgcc/config/i386/cygwin.S:117 #1 0x00000001407b4b86 in irange::irange_intersect (this=0x40ea30, r=...) at ../../../../src/gcc-git-11.1.0/gcc/value-range.cc:1683 #2 0x0000000140de72d2 in irange::intersect (r=..., this=0x40ea30) at ../../../../src/gcc-git-11.1.0/gcc/value-range.h:546 #3 gimple_ranger::range_of_stmt (this=0x29769a0, r=..., s=<optimized out>, name=0x2ac1b88) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:1073 #4 0x0000000140de30a9 in gimple_ranger::range_of_expr (this=0x29769a0, r=..., expr=0x2ac1b88, stmt=<optimized out>) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:960 #5 0x0000000140de4681 in gimple_ranger::range_of_range_op (this=this@entry=0x29769a0, r=..., s=s@entry=0x2ac4000) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:438 #6 0x0000000140de6c77 in gimple_ranger::calc_stmt (this=this@entry=0x29769a0, r=..., s=s@entry=0x2ac4000, name=name@entry=0x2ac1c60) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:374 #7 0x0000000140de72b5 in gimple_ranger::range_of_stmt (this=0x29769a0, r=..., s=0x2ac4000, name=0x2ac1c60) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:1068 #8 0x0000000140de30a9 in gimple_ranger::range_of_expr (this=0x29769a0, r=..., expr=0x2ac1c60, stmt=<optimized out>) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:960 #9 0x0000000140de4681 in gimple_ranger::range_of_range_op (this=this@entry=0x29769a0, r=..., s=s@entry=0x2ac40b0) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:438 #10 0x0000000140de6c77 in gimple_ranger::calc_stmt (this=this@entry=0x29769a0, r=..., s=s@entry=0x2ac40b0, name=name@entry=0x2ac1d38) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:374 #11 0x0000000140de72b5 in gimple_ranger::range_of_stmt (this=0x29769a0, r=..., s=0x2ac40b0, name=0x2ac1d38) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:1068 #12 0x0000000140de30a9 in gimple_ranger::range_of_expr (this=0x29769a0, r=..., expr=0x2ac1d38, stmt=<optimized out>) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:960 #13 0x0000000140de4681 in gimple_ranger::range_of_range_op (this=this@entry=0x29769a0, r=..., s=s@entry=0x2ac4108) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:438 #14 0x0000000140de6c77 in gimple_ranger::calc_stmt (this=this@entry=0x29769a0, r=..., s=s@entry=0x2ac4108, name=name@entry=0x2b29678) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:374 --Type <RET> for more, q to quit, c to continue without paging-- #15 0x0000000140de72b5 in gimple_ranger::range_of_stmt (this=0x29769a0, r=..., s=0x2ac4108, name=0x2b29678) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:1068 #16 0x0000000140de30a9 in gimple_ranger::range_of_expr (this=0x29769a0, r=..., expr=0x2b29678, stmt=<optimized out>) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:960 #17 0x0000000140de46a9 in gimple_ranger::range_of_range_op (this=this@entry=0x29769a0, r=..., s=s@entry=0x2ac4160) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:443 #18 0x0000000140de6c77 in gimple_ranger::calc_stmt (this=this@entry=0x29769a0, r=..., s=s@entry=0x2ac4160, name=name@entry=0x2b296c0) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:374 #19 0x0000000140de72b5 in gimple_ranger::range_of_stmt (this=0x29769a0, r=..., s=0x2ac4160, name=0x2b296c0) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:1068 #20 0x0000000140de30a9 in gimple_ranger::range_of_expr (this=0x29769a0, r=..., expr=0x2b296c0, stmt=<optimized out>) ... #599 0x0000000140de30a9 in gimple_ranger::range_of_expr (this=0x29c1a70, r=..., expr=0x2a53288, stmt=<optimized out>) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:960 #600 0x0000000140de4681 in gimple_ranger::range_of_range_op (this=this@entry=0x29c1a70, r=..., s=s@entry=0x2a50f78) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:438 #601 0x0000000140de6c77 in gimple_ranger::calc_stmt (this=this@entry=0x29c1a70, r=..., s=s@entry=0x2a50f78, name=name@entry=0x2a8edc8) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:374 #602 0x0000000140de72b5 in gimple_ranger::range_of_stmt (this=0x29c1a70, r=..., s=0x2a50f78, name=0x2a8edc8) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:1068 #603 0x0000000140de30a9 in gimple_ranger::range_of_expr (this=0x29c1a70, r=..., expr=0x2a8edc8, stmt=<optimized out>) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:960 #604 0x0000000140de46a9 in gimple_ranger::range_of_range_op (this=this@entry=0x29c1a70, r=..., s=s@entry=0x2a54000) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:443 #605 0x0000000140de6c77 in gimple_ranger::calc_stmt (this=this@entry=0x29c1a70, r=..., s=s@entry=0x2a54000, name=name@entry=0x2a8ee10) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:374 #606 0x0000000140de72b5 in gimple_ranger::range_of_stmt (this=0x29c1a70, r=..., s=0x2a54000, name=0x2a8ee10) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:1068 #607 0x0000000140de30a9 in gimple_ranger::range_of_expr (this=0x29c1a70, r=..., expr=0x2a8ee10, stmt=<optimized out>) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:960 #608 0x0000000140de46a9 in gimple_ranger::range_of_range_op (this=this@entry=0x29c1a70, r=..., s=s@entry=0x2a540b0) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:443 #609 0x0000000140de6c77 in gimple_ranger::calc_stmt (this=this@entry=0x29c1a70, r=..., s=s@entry=0x2a540b0, name=name@entry=0x2a53318) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:374 #610 0x0000000140de72b5 in gimple_ranger::range_of_stmt (this=0x29c1a70, r=..., s=0x2a540b0, name=0x2a53318) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:1068 #611 0x0000000140de30a9 in gimple_ranger::range_of_expr (this=0x29c1a70, r=..., expr=0x2a53318, stmt=<optimized out>) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:960 #612 0x0000000140de21ea in gimple_ranger::range_on_edge (this=0x29c1a70, r=..., e=0x2a56120, name=0x2a53318) at ../../../../src/gcc-git-11.1.0/gcc/gimple-range.cc:1030 #613 0x00000001407ad28f in range_query::value_on_edge (this=0x29c1a70, e=<optimized out>, name=0x2a53318) at ../../../../src/gcc-git-11.1.0/gcc/value-query.cc:106 #614 0x0000000140df0cca in hybrid_folder::value_on_edge (this=0x5ff800, e=0x2a56120, op=0x2a53318) at ../../../../src/gcc-git-11.1.0/gcc/gimple-ssa-evrp.c:245 #615 0x000000014068c39b in substitute_and_fold_engine::replace_phi_args_in (this=0x5ff800, phi=phi@entry=0x295be00) at ../../../../src/gcc-git-11.1.0/gcc/tree-ssa-propagate.c:913 #616 0x000000014068c64d in substitute_and_fold_dom_walker::before_dom_children (this=0x5ff750, bb=0x2a089a0) at ../../../../src/gcc-git-11.1.0/gcc/tree-ssa-propagate.c:1087 #617 0x0000000140dbe846 in dom_walker::walk (this=0x5ff750, bb=0x2a089a0) at ../../../../src/gcc-git-11.1.0/gcc/domwalk.c:309 #618 0x000000014068bd58 in substitute_and_fold_engine::substitute_and_fold (this=<optimized out>, block=block@entry=0x0) at ../../../../src/gcc-git-11.1.0/gcc/tree-ssa-propagate.c:1283 #619 0x0000000140df090d in execute_early_vrp () at ../../../../src/gcc-git-11.1.0/gcc/gimple-ssa-evrp.c:349 #620 0x00000001404705e5 in execute_one_pass (pass=pass@entry=0x2500630) at ../../../../src/gcc-git-11.1.0/gcc/passes.c:2567 #621 0x0000000140470f78 in execute_pass_list_1 (pass=0x2500630) at ../../../../src/gcc-git-11.1.0/gcc/passes.c:2656 #622 0x0000000140470f8a in execute_pass_list_1 (pass=0x2500120) at ../../../../src/gcc-git-11.1.0/gcc/passes.c:2657 #623 0x0000000140470fc1 in execute_pass_list (fn=0x28ba0c0, pass=<optimized out>) at ../../../../src/gcc-git-11.1.0/gcc/passes.c:2667 #624 0x000000014046dca3 in do_per_function_toporder (callback=callback@entry=0x140470fa0 <execute_pass_list(function*, opt_pass*)>, data=0x24ffee0) at ../../../../src/gcc-git-11.1.0/gcc/passes.c:1773 #625 0x0000000140471540 in do_per_function_toporder (data=<optimized out>, callback=0x140470fa0 <execute_pass_list(function*, opt_pass*)>) at ../../../../src/gcc-git-11.1.0/gcc/passes.c:1741 #626 execute_ipa_pass_list (pass=0x24ffe50) at ../../../../src/gcc-git-11.1.0/gcc/passes.c:3001 #627 0x00000001401771b0 in ipa_passes () at ../../../../src/gcc-git-11.1.0/gcc/cgraphunit.c:2156 #628 symbol_table::compile (this=this@entry=0x24db000) at ../../../../src/gcc-git-11.1.0/gcc/cgraphunit.c:2291 #629 0x0000000140179834 in symbol_table::compile (this=0x24db000) at ../../../../src/gcc-git-11.1.0/gcc/cgraphunit.c:2271 #630 symbol_table::finalize_compilation_unit (this=0x24db000) at ../../../../src/gcc-git-11.1.0/gcc/cgraphunit.c:2539 #631 0x000000014053336c in compile_file () at ../../../../src/gcc-git-11.1.0/gcc/toplev.c:482 #632 0x00000001411192f3 in do_compile () at ../../../../src/gcc-git-11.1.0/gcc/toplev.c:2201 #633 toplev::main (this=this@entry=0x5ffe0e, argc=<optimized out>, argc@entry=36, argv=<optimized out>, argv@entry=0x161910) at ../../../../src/gcc-git-11.1.0/gcc/toplev.c:2340 #634 0x0000000141144677 in main (argc=36, argv=0x161910) at ../../../../src/gcc-git-11.1.0/gcc/main.c:39 Eventually __chkstk_ms encounters a segfault. Thread 1 received signal SIGSEGV, Segmentation fault. ___chkstk_ms () at ../../../../../src/gcc-git-10.3.0/libgcc/config/i386/cygwin.S:126 126 ../../../../../src/gcc-git-10.3.0/libgcc/config/i386/cygwin.S: No such file or directory. (gdb) bt #0 ___chkstk_ms () at ../../../../../src/gcc-git-10.3.0/libgcc/config/i386/cygwin.S:126 #1 0x0000000000001040 in ?? () Backtrace stopped: previous frame inner to this frame (corrupt stack?)