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

            Bug ID: 119785
           Summary: UBSAN errors in machmode.h on sparc
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sjames at gcc dot gnu.org
            Blocks: 63426
  Target Milestone: ---

trunk + sparc64-unknown-linux-gnu with bootstrap-ubsan:
```
/root/gcc/gcc/machmode.h:576:46: runtime error: index 63 out of bounds for type
'poly_int [63]'
    #0 0x000002d6ba10 in mode_to_bytes(machine_mode)
/root/gcc/gcc/machmode.h:576
    #1 0x000002d6ba10 in GET_MODE_SIZE(machine_mode)
/root/gcc/gcc/machmode.h:659
    #2 0x000002d6ba10 in rtx_cost(rtx_def*, machine_mode, rtx_code, int, bool)
/root/gcc/gcc/rtlanal.cc:4554
    #3 0x00000142dd34 in set_src_cost(rtx_def*, machine_mode, bool)
/root/gcc/gcc/rtl.h:2967
    #4 0x00000142dd34 in init_expmed() /root/gcc/gcc/expmed.cc:288
    #5 0x0000031859b8 in backend_init_target /root/gcc/gcc/toplev.cc:1800
    #6 0x0000031859b8 in initialize_rtl() /root/gcc/gcc/toplev.cc:1867
    #7 0x00000173162c in init_function_start(tree_node*)
/root/gcc/gcc/function.cc:5026
    #8 0x000000ec3b60 in cgraph_node::expand() /root/gcc/gcc/cgraphunit.cc:1844
    #9 0x000000ec3b60 in cgraph_node::expand() /root/gcc/gcc/cgraphunit.cc:1812
    #10 0x000000ee1b0c in expand_all_functions /root/gcc/gcc/cgraphunit.cc:2042
    #11 0x000000ee1b0c in symbol_table::compile()
/root/gcc/gcc/cgraphunit.cc:2418
    #12 0x000000ee1b0c in symbol_table::compile()
/root/gcc/gcc/cgraphunit.cc:2327
    #13 0x000000ee429c in symbol_table::finalize_compilation_unit()
/root/gcc/gcc/cgraphunit.cc:2607
    #14 0x000003181bec in compile_file /root/gcc/gcc/toplev.cc:479
    #15 0x0000003f8bf4 in do_compile /root/gcc/gcc/toplev.cc:2208
    #16 0x0000003f8bf4 in toplev::main(int, char**)
/root/gcc/gcc/toplev.cc:2371
    #17 0x0000003fd52c in main /root/gcc/gcc/main.cc:39
    #18 0xfff800010132c660  (/usr/lib64/libc.so.6+0x2c660)
    #19 0xfff800010132c768 in __libc_start_main (/usr/lib64/libc.so.6+0x2c768)
    #20 0x0000003fd9fc in _start (/tmp/build/gcc/cc1+0x3fd9fc)

/root/gcc/gcc/machmode.h:576:47: runtime error: load of address 0x000007874bb4
with insufficient space for an object of type 'const struct poly_uint16'
0x000007874bb4: note: pointer points here
  00 10 00 10 00 00 00 00  00 20 00 20 00 20 00 20  00 20 00 20 00 20 00 20  00
20 00 20 00 01 00 08
              ^
    #0 0x000002d6b9f8 in mode_to_bytes(machine_mode)
/root/gcc/gcc/machmode.h:576
    #1 0x000002d6b9f8 in GET_MODE_SIZE(machine_mode)
/root/gcc/gcc/machmode.h:659
    #2 0x000002d6b9f8 in rtx_cost(rtx_def*, machine_mode, rtx_code, int, bool)
/root/gcc/gcc/rtlanal.cc:4554
    #3 0x00000142dd34 in set_src_cost(rtx_def*, machine_mode, bool)
/root/gcc/gcc/rtl.h:2967
    #4 0x00000142dd34 in init_expmed() /root/gcc/gcc/expmed.cc:288
    #5 0x0000031859b8 in backend_init_target /root/gcc/gcc/toplev.cc:1800
    #6 0x0000031859b8 in initialize_rtl() /root/gcc/gcc/toplev.cc:1867
    #7 0x00000173162c in init_function_start(tree_node*)
/root/gcc/gcc/function.cc:5026
    #8 0x000000ec3b60 in cgraph_node::expand() /root/gcc/gcc/cgraphunit.cc:1844
    #9 0x000000ec3b60 in cgraph_node::expand() /root/gcc/gcc/cgraphunit.cc:1812
    #10 0x000000ee1b0c in expand_all_functions /root/gcc/gcc/cgraphunit.cc:2042
    #11 0x000000ee1b0c in symbol_table::compile()
/root/gcc/gcc/cgraphunit.cc:2418
    #12 0x000000ee1b0c in symbol_table::compile()
/root/gcc/gcc/cgraphunit.cc:2327
    #13 0x000000ee429c in symbol_table::finalize_compilation_unit()
/root/gcc/gcc/cgraphunit.cc:2607
    #14 0x000003181bec in compile_file /root/gcc/gcc/toplev.cc:479
    #15 0x0000003f8bf4 in do_compile /root/gcc/gcc/toplev.cc:2208
    #16 0x0000003f8bf4 in toplev::main(int, char**)
/root/gcc/gcc/toplev.cc:2371
    #17 0x0000003fd52c in main /root/gcc/gcc/main.cc:39
    #18 0xfff800010132c660  (/usr/lib64/libc.so.6+0x2c660)
    #19 0xfff800010132c768 in __libc_start_main (/usr/lib64/libc.so.6+0x2c768)
    #20 0x0000003fd9fc in _start (/tmp/build/gcc/cc1+0x3fd9fc)
```


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63426
[Bug 63426] [meta-bug] Issues found with -fsanitize=undefined

Reply via email to