Bug 84635 - gcc/regrename.c:1706:64: runtime error: index -1 out of bounds for type 'machine_mode [30]'
Summary: gcc/regrename.c:1706:64: runtime error: index -1 out of bounds for type 'mach...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 8.0.1
: P3 normal
Target Milestone: ---
Assignee: Martin Liška
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2018-03-01 07:51 UTC by Martin Liška
Modified: 2018-03-18 20:20 UTC (History)
0 users

See Also:
Host:
Target: x86_64-*-*, i?86-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-03-16 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 2018-03-01 07:51:39 UTC
Following test-case:

$ cat error.i
a () { a (); }

$ UBSAN_OPTIONS="print_stacktrace=1" /dev/shm/objdir/gcc/xgcc -B /dev/shm/objdir/gcc/ -O1 -funroll-loops -c error.i -fmax-errors=1
error.i:1:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
 a () { a (); }
 ^
/home/marxin/Programming/gcc2/gcc/regrename.c:1706:64: runtime error: index -1 out of bounds for type 'machine_mode [30]'
    #0 0x169bea1 in build_def_use /home/marxin/Programming/gcc2/gcc/regrename.c:1706
    #1 0x1694d2f in regrename_analyze(bitmap_head*) /home/marxin/Programming/gcc2/gcc/regrename.c:742
    #2 0x169dace in regrename_optimize /home/marxin/Programming/gcc2/gcc/regrename.c:1934
    #3 0x169dbc6 in execute /home/marxin/Programming/gcc2/gcc/regrename.c:1971
    #4 0x1598c61 in execute_one_pass(opt_pass*) /home/marxin/Programming/gcc2/gcc/passes.c:2497
    #5 0x159942b in execute_pass_list_1 /home/marxin/Programming/gcc2/gcc/passes.c:2586
    #6 0x15994a2 in execute_pass_list_1 /home/marxin/Programming/gcc2/gcc/passes.c:2587
    #7 0x15994a2 in execute_pass_list_1 /home/marxin/Programming/gcc2/gcc/passes.c:2587
    #8 0x1599522 in execute_pass_list(function*, opt_pass*) /home/marxin/Programming/gcc2/gcc/passes.c:2597
    #9 0xc40833 in cgraph_node::expand() /home/marxin/Programming/gcc2/gcc/cgraphunit.c:2139
    #10 0xc41740 in expand_all_functions /home/marxin/Programming/gcc2/gcc/cgraphunit.c:2275
    #11 0xc430b8 in symbol_table::compile() /home/marxin/Programming/gcc2/gcc/cgraphunit.c:2624
    #12 0xc43639 in symbol_table::finalize_compilation_unit() /home/marxin/Programming/gcc2/gcc/cgraphunit.c:2717
    #13 0x18a7f43 in compile_file /home/marxin/Programming/gcc2/gcc/toplev.c:480
    #14 0x18abd24 in do_compile /home/marxin/Programming/gcc2/gcc/toplev.c:2132
    #15 0x18ac208 in toplev::main(int, char**) /home/marxin/Programming/gcc2/gcc/toplev.c:2267
    #16 0x31e0f41 in main /home/marxin/Programming/gcc2/gcc/main.c:39
    #17 0x7ffff5cfbf49 in __libc_start_main (/lib64/libc.so.6+0x20f49)
    #18 0x81e9d9 in _start (/dev/shm/objdir/gcc/cc1+0x81e9d9)
Comment 1 Martin Liška 2018-03-16 15:03:46 UTC
So let me take a look.
Comment 2 Martin Liška 2018-03-18 20:17:42 UTC
Author: marxin
Date: Sun Mar 18 20:17:10 2018
New Revision: 258634

URL: https://gcc.gnu.org/viewcvs?rev=258634&root=gcc&view=rev
Log:
Fix UBSAN in regrename.c (PR rtl-optimization/84635).

2018-03-18  Martin Liska  <mliska@suse.cz>

	PR rtl-optimization/84635
	* regrename.c (build_def_use): Use matches_mode only when
	matches >= 0.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/regrename.c
Comment 3 Martin Liška 2018-03-18 20:20:07 UTC
Fixed.