Bug 104064 - gcc/tree-vect-data-refs.c:3208:16: runtime error: signed integer overflow: 17 - -9223372036854775806 cannot be represented in type 'long int'
Summary: gcc/tree-vect-data-refs.c:3208:16: runtime error: signed integer overflow: 17...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 12.0
: P3 normal
Target Milestone: ---
Assignee: Richard Biener
URL:
Keywords:
Depends on:
Blocks: ubsan
  Show dependency treegraph
 
Reported: 2022-01-17 10:54 UTC by Martin Liška
Modified: 2022-01-18 09:29 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2022-01-18 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2022-01-17 10:54:53 UTC
We may have a dup of it as g[2305843009213693952ULL].c is telling for an UBSAN ;)

$ ./xgcc -B. /home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/torture/pr103816.c -c -O2
/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-ubsan/build/gcc/tree-vect-data-refs.c:3208:16: runtime error: signed integer overflow: 17 - -9223372036854775806 cannot be represented in type 'long int'
    #0 0x741ec5b in vect_analyze_data_ref_accesses(vec_info*, vec<int, va_heap, vl_ptr>*) /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-ubsan/build/gcc/tree-vect-data-refs.c:3208
    #1 0x34df715 in vect_slp_analyze_bb_1 /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-ubsan/build/gcc/tree-vect-slp.c:5728
    #2 0x34df715 in vect_slp_region /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-ubsan/build/gcc/tree-vect-slp.c:5864
    #3 0x34ec6b5 in vect_slp_bbs /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-ubsan/build/gcc/tree-vect-slp.c:6056
    #4 0x34ed913 in vect_slp_function(function*) /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-ubsan/build/gcc/tree-vect-slp.c:6144
    #5 0x3547f13 in execute /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-ubsan/build/gcc/tree-vectorizer.c:1503
    #6 0x224e7e8 in execute_one_pass(opt_pass*) /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-ubsan/build/gcc/passes.c:2637
    #7 0x2251b34 in execute_pass_list_1 /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-ubsan/build/gcc/passes.c:2737
    #8 0x2251b7b in execute_pass_list_1 /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-ubsan/build/gcc/passes.c:2738
    #9 0x2251b7b in execute_pass_list_1 /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-ubsan/build/gcc/passes.c:2738
    #10 0x2251c45 in execute_pass_list(function*, opt_pass*) /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-ubsan/build/gcc/passes.c:2748
    #11 0xff3c2d in cgraph_node::expand() /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-ubsan/build/gcc/cgraphunit.c:1834
    #12 0xff91be in expand_all_functions /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-ubsan/build/gcc/cgraphunit.c:1998
    #13 0xff91be in symbol_table::compile() /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-ubsan/build/gcc/cgraphunit.c:2348
    #14 0xff91be in symbol_table::compile() /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-ubsan/build/gcc/cgraphunit.c:2259
    #15 0x1007b3a in symbol_table::finalize_compilation_unit() /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-ubsan/build/gcc/cgraphunit.c:2529
    #16 0x27a309f in compile_file /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-ubsan/build/gcc/toplev.c:479
    #17 0x98cf39 in do_compile /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-ubsan/build/gcc/toplev.c:2158
    #18 0x98cf39 in toplev::main(int, char**) /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-ubsan/build/gcc/toplev.c:2310
    #19 0x992531 in main /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-ubsan/build/gcc/main.c:39
    #20 0x7ffff78855bf in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #21 0x7ffff788567b in __libc_start_main_impl ../csu/libc-start.c:409
    #22 0x992754 in _start (/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-ubsan/objdir/gcc/cc1+0x992754)
Comment 1 Richard Biener 2022-01-18 08:08:59 UTC
I have a patch.
Comment 2 GCC Commits 2022-01-18 09:29:10 UTC
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:00dc7877ee02634d4837d024e36b55bef6b9d49c

commit r12-6660-g00dc7877ee02634d4837d024e36b55bef6b9d49c
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Jan 18 09:06:13 2022 +0100

    tree-optimization/104064 - UBSAN issue in vect dataref analysis
    
    Since we order DRs after DR_INIT we know the difference will be
    positive and thus can avoid signed overflow issues by using
    unsigned arithmetic to produce the known unsigned result.
    
    2022-01-18  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/104064
            * tree-vect-data-refs.cc (vect_analyze_data_ref_accesses): Check
            DR_INIT fits in a signed HWI, represent the difference from the
            first DR in unsigned.
Comment 3 Richard Biener 2022-01-18 09:29:20 UTC
Fixed.