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

            Bug ID: 100206
           Summary: aarch64: UB in varasm.c:output_object_block and
                    assembly failure
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: acoplan at gcc dot gnu.org
  Target Milestone: ---

Bootstrapping on aarch64 with --with-build-config=bootstrap-ubsan gives:

$ gcc/xgcc -B gcc ~/toolchain/src/gcc/gcc/testsuite/gcc.dg/strlenopt-55.c -c -O
/home/alecop01/toolchain/src/gcc/gcc/testsuite/gcc.dg/strlenopt-55.c:128:3:
warning: unsigned conversion from ‘int’ to ‘short unsigned int’ changes value
from ‘65536’ to ‘0’ [-Woverflow]
  128 |   0x10000   /* { dg-warning "\\\[-Woverflow]" } */
      |   ^~~~~~~
/home/alecop01/toolchain/src/gcc/gcc/poly-int.h:1095:5: runtime error: signed
integer overflow: 9223372036854775805 * 8 cannot be represented in type 'long
int'
    #0 0x26a75c0 in poly_int<2u, poly_result<long, if_nonpoly<int, int,
poly_int_traits<int>::is_poly>::type, poly_coeff_pair_traits<long,
if_nonpoly<int, int, poly_int_traits<int>::is_poly>::type>::result_kind>::type>
operator*<2u, long, int>(poly_int_pod<2u, long> const&, int const&)
/home/alecop01/toolchain/src/gcc/gcc/poly-int.h:1095
    #1 0x26a75c0 in fully_constant_vn_reference_p(vn_reference_s*)
/home/alecop01/toolchain/src/gcc/gcc/tree-ssa-sccvn.c:1540
<snip: see PR100201>

/home/alecop01/toolchain/src/gcc/gcc/varasm.c:8025:56: runtime error: signed
integer overflow: -9223372036854775808 - 9223372036854775807 cannot be
represented in type 'long int'
    #0 0x2cee540 in output_object_block
/home/alecop01/toolchain/src/gcc/gcc/varasm.c:8025
    #1 0x2cee540 in output_object_blocks()
/home/alecop01/toolchain/src/gcc/gcc/varasm.c:8117
    #2 0x1f972ec in compile_file
/home/alecop01/toolchain/src/gcc/gcc/toplev.c:518
    #3 0x68d9b0 in do_compile
/home/alecop01/toolchain/src/gcc/gcc/toplev.c:2201
    #4 0x68d9b0 in toplev::main(int, char**)
/home/alecop01/toolchain/src/gcc/gcc/toplev.c:2340
    #5 0x6910d0 in main /home/alecop01/toolchain/src/gcc/gcc/main.c:39
    #6 0xffffa5d236dc in __libc_start_main
(/lib/aarch64-linux-gnu/libc.so.6+0x206dc)
    #7 0x691b2c  (/data/alecop01/builds/bstrap-ubsan/gcc/cc1+0x691b2c)

/tmp/ccdfBbbL.s: Assembler messages:
/tmp/ccdfBbbL.s: Fatal error: can't write 4 bytes to section .text of
strlenopt-55.o: 'File truncated'
/usr/bin/as: BFD (GNU Binutils for Ubuntu) 2.30 assertion fail
../../bfd/elf.c:3092
/tmp/ccdfBbbL.s: Fatal error: can't close strlenopt-55.o: File truncated

showing both UB in varasm.c and an assemble failure.

Reply via email to