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

            Bug ID: 116042
           Summary: ICE Segmentation fault  ( in
                    ix86_finalize_stack_frame_flags and
                    ix86_expand_prologue())
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: iamanonymous.cs at gmail dot com
  Target Milestone: ---
            Target: x86_64

Created attachment 58727
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58727&action=edit
c testcase

*******************************************************************************
The compiler produces a segfault during ix86_finalize_stack_frame_flags when
compiling the provided code with the specified options. 
The issue can also be reproduced on Compiler Explorer.

*******************************************************************************
OS and Platform:
# uname -a
Linux ubuntu 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023
x86_64 x86_64 x86_64 GNU/Linux
*******************************************************************************
# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/root/gdbtest/gcc/gcc-15/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /root/gdbtest/gcc/obj/../gcc/configure
--prefix=/root/gdbtest/gcc/gcc-15 --enable-languages=c,c++,fortran,go
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240509 (experimental) (GCC) 
*******************************************************************************
Program:Please refer to the attachment. 

*******************************************************************************
Command Lines:
gcc helper.i -O2 -fno-omit-frame-pointer -fno-stack-protector
-fno-strict-aliasing -g3 -Wall -Wextra -Werror -Wno-pointer-arith
-Wno-missing-field-initializers -pedantic -DDEBUG -c -o helper.o

In file included from /tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:20:
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/exec.h:23:17: error: file-scope
declaration of ‘env’ specifies ‘register’ [-Werror=pedantic]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/exec.h:24:1: error: file-scope
declaration of ‘T0’ specifies ‘register’ [-Werror=pedantic]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/exec.h:25:1: error: file-scope
declaration of ‘T1’ specifies ‘register’ [-Werror=pedantic]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/exec.h:25:19: error: call-clobbered
register used for global register variable [-Werror]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/exec.h:26:1: error: file-scope
declaration of ‘T2’ specifies ‘register’ [-Werror=pedantic]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/exec.h:26:19: error: call-clobbered
register used for global register variable [-Werror]
In file included from /tmp/qemu/BUILD/qemu-0.5.5/target-i386/cpu.h:452,
                 from /tmp/qemu/BUILD/qemu-0.5.5/target-i386/exec.h:115:
/tmp/qemu/BUILD/qemu-0.5.5/cpu-all.h: In function ‘tswap16s’:
/tmp/qemu/BUILD/qemu-0.5.5/cpu-all.h:95:39: error: unused parameter ‘s’
[-Werror=unused-parameter]
/tmp/qemu/BUILD/qemu-0.5.5/cpu-all.h: In function ‘tswap32s’:
/tmp/qemu/BUILD/qemu-0.5.5/cpu-all.h:99:39: error: unused parameter ‘s’
[-Werror=unused-parameter]
/tmp/qemu/BUILD/qemu-0.5.5/cpu-all.h: In function ‘tswap64s’:
/tmp/qemu/BUILD/qemu-0.5.5/cpu-all.h:103:39: error: unused parameter ‘s’
[-Werror=unused-parameter]
In file included from /tmp/qemu/BUILD/qemu-0.5.5/target-i386/exec.h:116:
/tmp/qemu/BUILD/qemu-0.5.5/exec-all.h: In function ‘spin_lock’:
/tmp/qemu/BUILD/qemu-0.5.5/exec-all.h:518:42: error: unused parameter ‘lock’
[-Werror=unused-parameter]
/tmp/qemu/BUILD/qemu-0.5.5/exec-all.h: In function ‘spin_unlock’:
/tmp/qemu/BUILD/qemu-0.5.5/exec-all.h:522:44: error: unused parameter ‘lock’
[-Werror=unused-parameter]
/tmp/qemu/BUILD/qemu-0.5.5/exec-all.h: In function ‘spin_trylock’:
/tmp/qemu/BUILD/qemu-0.5.5/exec-all.h:526:44: error: unused parameter ‘lock’
[-Werror=unused-parameter]
/tmp/qemu/BUILD/qemu-0.5.5/exec-all.h: In function ‘get_phys_addr_code’:
/tmp/qemu/BUILD/qemu-0.5.5/exec-all.h:590:19: error: cast to pointer from
integer of different size [-Werror=int-to-pointer-cast]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/exec.h: At top level:
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/exec.h:310:12: error: conflicting types
for built-in function ‘lrintl’; expected ‘long int(long double)’
[-Werror=builtin-declaration-mismatch]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/exec.h:236:1: note: ‘lrintl’ is declared
in header ‘<math.h>’
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c: In function ‘load_segment’:
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:152:21: error: comparison of
integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka
‘unsigned int’} [-Werror=sign-compare]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c: In function ‘get_seg_base’:
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:171:12: error: cast to pointer
from integer of different size [-Werror=int-to-pointer-cast]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c: In function ‘load_seg_vm’:
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:186:28: error: cast to pointer
from integer of different size [-Werror=int-to-pointer-cast]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c: In function
‘get_ss_esp_from_tss’:
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:213:34: error: comparison of
integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka
‘unsigned int’} [-Werror=sign-compare]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c: In function ‘switch_tss’:
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:467:25: error: comparison of
integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka
‘unsigned int’} [-Werror=sign-compare]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:286:53: error: variable
‘new_trap’ set but not used [-Werror=unused-but-set-variable]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c: In function ‘check_io’:
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:509:25: error: comparison of
integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka
‘unsigned int’} [-Werror=sign-compare]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c: In function
‘do_interrupt_protected’:
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:615:23: error: comparison of
integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka
‘unsigned int’} [-Werror=sign-compare]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:681:22: error: comparison of
integer expressions of different signedness: ‘uint32_t’ {aka ‘unsigned int’}
and ‘int’ [-Werror=sign-compare]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c: In function
‘do_interrupt_real’:
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:799:23: error: comparison of
integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka
‘unsigned int’} [-Werror=sign-compare]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:820:25: error: cast to pointer
from integer of different size [-Werror=int-to-pointer-cast]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:788:58: error: unused parameter
‘error_code’ [-Werror=unused-parameter]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c: In function
‘do_interrupt_user’:
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:825:51: error: unused parameter
‘error_code’ [-Werror=unused-parameter]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c: In function
‘helper_cmpxchg8b’:
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:989:18: error: cast to pointer
from integer of different size [-Werror=int-to-pointer-cast]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:991:18: error: cast to pointer
from integer of different size [-Werror=int-to-pointer-cast]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c: In function ‘helper_lldt_T0’:
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:1082:25: error: comparison of
integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka
‘unsigned int’} [-Werror=sign-compare]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c: In function ‘helper_ltr_T0’:
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:1115:25: error: comparison of
integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka
‘unsigned int’} [-Werror=sign-compare]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c: In function ‘load_seg’:
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:1155:25: error: comparison of
integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka
‘unsigned int’} [-Werror=sign-compare]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c: In function
‘helper_ljmp_protected_T0_T1’:
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:1240:21: error: comparison of
integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka
‘unsigned int’} [-Werror=sign-compare]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:1282:25: error: comparison of
integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka
‘unsigned int’} [-Werror=sign-compare]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c: In function
‘helper_lcall_real_T0_T1’:
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:1318:25: error: cast to pointer
from integer of different size [-Werror=int-to-pointer-cast]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c: In function
‘helper_lcall_protected_T0_T1’:
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:1380:21: error: comparison of
integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka
‘unsigned int’} [-Werror=sign-compare]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c: In function
‘helper_ret_protected’:
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:1648:26: error: comparison of
integer expressions of different signedness: ‘uint32_t’ {aka ‘unsigned int’}
and ‘int’ [-Werror=sign-compare]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c: In function
‘helper_fldt_ST0_A0’:
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:1983:42: error: cast to pointer
from integer of different size [-Werror=int-to-pointer-cast]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c: In function
‘helper_fstt_ST0_A0’:
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:1990:44: error: cast to pointer
from integer of different size [-Werror=int-to-pointer-cast]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c: In function
‘helper_fbld_ST0_A0’:
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:2004:23: error: cast to pointer
from integer of different size [-Werror=int-to-pointer-cast]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:2008:19: error: cast to pointer
from integer of different size [-Werror=int-to-pointer-cast]
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c: In function
‘helper_fbst_ST0_A0’:
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/helper.c:2023:15: error: cast to pointer
from integer of different size [-Werror=int-to-pointer-cast]
In file included from /tmp/qemu/BUILD/qemu-0.5.5/cpu-defs.h:25,
                 from /tmp/qemu/BUILD/qemu-0.5.5/target-i386/cpu.h:31:
/usr/include/inttypes.h: In function ‘strtoimax’:
/usr/include/inttypes.h:397:1: error: frame pointer required, but reserved
  397 | }
      | ^        
/tmp/qemu/BUILD/qemu-0.5.5/target-i386/exec.h:23:30: note: for ‘env’
during RTL pass: pro_and_epilogue
/usr/include/inttypes.h:401:8: internal compiler error: Segmentation fault
  401 |                                          __gwchar_t **__restrict
__endptr,
      | ^       
0x10a7f2f crash_signal
        /home/gcc/gcc/toplev.cc:319
0x148f0a5 ix86_finalize_stack_frame_flags
        /home/gcc/gcc/config/i386/i386.cc:8606
0x149058c ix86_expand_prologue()
        /home/gcc/gcc/config/i386/i386.cc:8777
0x1b021aa gen_prologue()
        /home/gcc/gcc/config/i386/i386.md:19176
0x147af65 target_gen_prologue
        /home/gcc/gcc/config/i386/i386.md:27088
0xcf7f27 make_prologue_seq
        /home/gcc/gcc/function.cc:5818
0xcf80e3 thread_prologue_and_epilogue_insns()
        /home/gcc/gcc/function.cc:6053
0xcf8852 rest_of_handle_thread_prologue_and_epilogue
        /home/gcc/gcc/function.cc:6567
0xcf8852 execute
        /home/gcc/gcc/function.cc:6653
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.


*******************************************************************************

Also ICE on trunk, compiler explorer:https://godbolt.org/z/f1zqxr8Ko

*******************************************************************************

Reply via email to