https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107506

            Bug ID: 107506
           Summary: [regression]
                    cross-xtensa-esp32s2-elf/gcc-13.0.0_pre20221023: stack
                    smashing detected during RTL pass: expand in function
                    __absvdi2 (gen_movdi)
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: triffid.hunter at gmail dot com
  Target Milestone: ---

While compiling xtensa-esp32s2-elf-gcc-13.0.0_pre20221023 (via Gentoo ebuild,
further info at https://bugs.gentoo.org/879049 ):

/var/tmp/portage/cross-xtensa-esp32s2-elf/gcc-13.0.0_pre20221023/work/build/xtensa-esp32s2-elf/libgcc
[1] #
/var/tmp/portage/cross-xtensa-esp32s2-elf/gcc-13.0.0_pre20221023/work/build/./gcc/xgcc
-freport-bug
-B/var/tmp/portage/cross-xtensa-esp32s2-elf/gcc-13.0.0_pre20221023/work/build/./gcc/
-B/usr/xtensa-esp32s2-elf/bin/ -B/usr/xtensa-esp32s2-elf/lib/ -isystem
/usr/xtensa-esp32s2-elf/include -isystem /usr/xtensa-esp32s2-elf/sys-include   
-g -O2 -O2  -g -O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -W -Wall
-Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes
-Wmissing-prototypes -Wold-style-definition  -isystem ./include  -mlongcalls -g
-DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -fno-stack-clash-protection
-Dinhibit_libc -mlongcalls -I. -I. -I../.././gcc
-I/var/tmp/portage/cross-xtensa-esp32s2-elf/gcc-13.0.0_pre20221023/work/gcc-13-20221023/libgcc
-I/var/tmp/portage/cross-xtensa-esp32s2-elf/gcc-13.0.0_pre20221023/work/gcc-13-20221023/libgcc/.
-I/var/tmp/portage/cross-xtensa-esp32s2-elf/gcc-13.0.0_pre20221023/work/gcc-13-20221023/libgcc/../gcc
-I/var/tmp/portage/cross-xtensa-esp32s2-elf/gcc-13.0.0_pre20221023/work/gcc-13-20221023/libgcc/../include
 -DHAVE_CC_TLS   -o _absvdi2.o -MT _absvdi2.o -MD -MP -MF _absvdi2.dep
-DL_absvdi2 -c
/var/tmp/portage/cross-xtensa-esp32s2-elf/gcc-13.0.0_pre20221023/work/gcc-13-20221023/libgcc/libgcc2.c
-fvisibility=hidden -DHIDE_EXPORTS
*** stack smashing detected ***: terminated
during RTL pass: expand
/var/tmp/portage/cross-xtensa-esp32s2-elf/gcc-13.0.0_pre20221023/work/gcc-13-20221023/libgcc/libgcc2.c:
In function '__absvdi2':
/var/tmp/portage/cross-xtensa-esp32s2-elf/gcc-13.0.0_pre20221023/work/gcc-13-20221023/libgcc/libgcc2.c:244:22:
internal compiler error: Aborted
244 |   const DWtype v = 0 - (a < 0);
|                    ~~^~~~~~~~~
0x139ab2a diagnostic_impl(rich_location*, diagnostic_metadata const*, int, char
const*, __va_list_tag (*) [1], diagnostic_t)
???:0
0x139ba08 internal_error(char const*, ...)
???:0
0xb167ef crash_signal(int)
???:0
0x7fc8c6e4c731 raise
???:0
0x7fc8c6e37468 abort
???:0
0x7fc8c6f279a1 __fortify_fail
???:0
0x7fc8c6f2797f __stack_chk_fail
???:0
0x115effa gen_movdi(rtx_def*, rtx_def*)
???:0
0x7dcd97 emit_move_insn_1(rtx_def*, rtx_def*)
???:0
0x7e41dc gen_move_insn(rtx_def*, rtx_def*)
???:0
0x7c782f canonicalize_comparison(machine_mode, rtx_code*, rtx_def**)
???:0
0x7c7bd4 emit_store_flag_1(rtx_def*, rtx_code, rtx_def*, rtx_def*,
machine_mode, int, int, machine_mode)
???:0
0x7c8114 emit_store_flag(rtx_def*, rtx_code, rtx_def*, rtx_def*, machine_mode,
int, int)
???:0
0x7c8c3d emit_store_flag_force(rtx_def*, rtx_code, rtx_def*, rtx_def*,
machine_mode, int, int)
???:0
0x7d3d4f do_store_flag(separate_ops*, rtx_def*, machine_mode)
???:0
0x7d49b4 expand_expr_real_2(separate_ops*, rtx_def*, machine_mode,
expand_modifier)
???:0
0x7db5b5 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
???:0
0x7d4ca1 expand_expr_real_2(separate_ops*, rtx_def*, machine_mode,
expand_modifier)
???:0
0x7db5b5 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
???:0
0x7d5abe expand_expr_real_2(separate_ops*, rtx_def*, machine_mode,
expand_modifier)
???:0
Please submit a full bug report, with preprocessed source.
Please include the complete backtrace with any bug report.
See <https://bugs.gentoo.org/> for instructions.
The bug is not reproducible, so it is likely a hardware or OS problem.

---

Despite the output saying "this bug is not reproducible", I seem to be able to
reliably reproduce it at the moment.

Even after a cold reboot, it dies at __subvdi3 but the backtrace still
implicates gen_movdi - race condition on the compile target or something I
guess?

After reboot terminal output:

make[2]: Entering directory
'/var/tmp/portage/cross-xtensa-esp32s2-elf/gcc-13.0.0_pre20221023/work/build/xtensa-esp32s2-elf/libgcc'
/var/tmp/portage/cross-xtensa-esp32s2-elf/gcc-13.0.0_pre20221023/work/build/./gcc/xgcc
-B/var/tmp/portage/cross-xtensa-esp32s2-elf/gcc-13.0.0_pre20221023/work/build/./gcc/
-B/usr/xtensa-esp32s2-elf/bin/ -B/usr/xtensa-esp32s2-elf/lib/ -isystem
/usr/xtensa-esp32s2-elf/include -isystem /usr/xtensa-esp32s2-elf/sys-include   
-g -O2 -O2  -g -O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -W -Wall
-Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes
-Wmissing-prototypes -Wold-style-definition  -isystem ./include  -mlongcalls -g
-DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -fno-stack-clash-protection
-Dinhibit_libc -mlongcalls -I. -I. -I../.././gcc
-I/var/tmp/portage/cross-xtensa-esp32s2-elf/gcc-13.0.0_pre20221023/work/gcc-13-20221023/libgcc-I/var/tmp/portage/cross-xtensa-esp32s2-elf/gcc-13.0.0_pre20221023/work/gcc-13-20221023/libgcc/.
-I/var/tmp/portage/cross-xtensa-esp32s2-elf/gcc-13.0.0_pre20221023/work/gcc-13-20221023/libgcc/../gcc
-I/var/tmp/portage/cross-xtensa-esp32s2-elf/gcc-13.0.0_pre20221023/work/gcc-13-20221023/libgcc/../include
 -DHAVE_CC_TLS   -o _subvdi3.o -MT _subvdi3.o -MD -MP -MF _subvdi3.dep
-DL_subvdi3 -c
/var/tmp/portage/cross-xtensa-esp32s2-elf/gcc-13.0.0_pre20221023/work/gcc-13-20221023/libgcc/libgcc2.c
-fvisibility=hidden -DHIDE_EXPORTS
*** stack smashing detected ***: terminated
during RTL pass: expand
/var/tmp/portage/cross-xtensa-esp32s2-elf/gcc-13.0.0_pre20221023/work/gcc-13-20221023/libgcc/libgcc2.c:
In function '__subvdi3':
/var/tmp/portage/cross-xtensa-esp32s2-elf/gcc-13.0.0_pre20221023/work/gcc-13-20221023/libgcc/libgcc2.c:143:7:
internal compiler error: Aborted
143 |   if (__builtin_sub_overflow (a, b, &w))
|       ^~~~~~~~~~~~~~~~~~~~~~
0x139ab2a diagnostic_impl(rich_location*, diagnostic_metadata const*, int, char
const*, __va_list_tag (*) [1], diagnostic_t)
???:0
0x139ba08 internal_error(char const*, ...)
???:0
0xb167ef crash_signal(int)
???:0
0x7fe6560a8731 raise
???:0
0x7fe656093468 abort
???:0
0x7fe6561839a1 __fortify_fail
???:0
0x7fe65618397f __stack_chk_fail
???:0
0x115effa gen_movdi(rtx_def*, rtx_def*)
???:0
0x7dcd97 emit_move_insn_1(rtx_def*, rtx_def*)
???:0
0x7dd19d emit_move_insn(rtx_def*, rtx_def*)
???:0
0x8be566 expand_addsub_overflow(unsigned int, tree_code, tree_node*,
tree_node*, tree_node*, bool, bool, bool, bool, tree_node**)
???:0
0x8c59c8 expand_arith_overflow(tree_code, gimple*)
???:0
0x6d7337 expand_gimple_stmt(gimple*)
???:0
0x6db937 expand_gimple_basic_block(basic_block_def*, bool)
???:0
0x6dd9b6 (anonymous namespace)::pass_expand::execute(function*)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://bugs.gentoo.org/> for instructions.

---

I previously compiled xtensa-esp32s2-elf-gcc-13.0.0_pre20220918 which did not
exhibit this issue.

I also tried gcc12.2.1_pre20221008 which succeeded.

I also successfully compiled avr-gcc-13.0.0_pre20221023, but compiling
xtensa-esp32-elf-gcc-13.0.0_pre20221023 (esp32 vs esp32s2) also runs into the
same issue so as far as I can tell this only affects xtensa-esp32* targets.

In case it's relevant, my host (x86_64) compiler version is gcc-11.3.0 - I only
use testing gcc releases for firmware, not my daily driver's OS ;)

https://gcc.gnu.org/bugzilla//show_bug.cgi?id=100106 looks similar in that it
dies at gen_movdi, but has a different target, backtrace, and gcc version.

https://bugs.gentoo.org/879049 has the intermediate files from -save-temps, I
can repost them here too if you prefer.

Reply via email to