Bug 84634 - [8 Regression] gcc/tree-vect-stmts.c:6786:19: runtime error: member access within null pointer of type 'struct _loop_vec_info
Summary: [8 Regression] gcc/tree-vect-stmts.c:6786:19: runtime error: member access wi...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: 8.0
Assignee: Richard Sandiford
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2018-03-01 07:49 UTC by Martin Liška
Modified: 2018-03-02 09:47 UTC (History)
2 users (show)

See Also:
Host:
Target: x86_64-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-03-01 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:49:16 UTC
Started probable since Richard's r256625:

$ UBSAN_OPTIONS="print_stacktrace=1" ./xgcc -B. /home/marxin/Programming/gcc/gcc/testsuite/gcc.c-torture/execute/20020129-1.c -O3
../../gcc/tree-vect-stmts.c:6786:19: runtime error: member access within null pointer of type 'struct _loop_vec_info'
    #0 0x2b6462b in vectorizable_store ../../gcc/tree-vect-stmts.c:6786
    #1 0x2ba7d19 in vect_transform_stmt(gimple*, gimple_stmt_iterator*, bool*, _slp_tree*, _slp_instance*) ../../gcc/tree-vect-stmts.c:9482
    #2 0x2c91d42 in vect_schedule_slp_instance ../../gcc/tree-vect-slp.c:4187
    #3 0x2c98669 in vect_schedule_slp(vec_info*) ../../gcc/tree-vect-slp.c:4256
    #4 0x2cabcad in vect_slp_bb(basic_block_def*) ../../gcc/tree-vect-slp.c:3250
    #5 0x2cba557 in execute ../../gcc/tree-vectorizer.c:978
    #6 0x1b8f0ac in execute_one_pass(opt_pass*) ../../gcc/passes.c:2497
    #7 0x1b92bc7 in execute_pass_list_1 ../../gcc/passes.c:2586
    #8 0x1b92c0e in execute_pass_list_1 ../../gcc/passes.c:2587
    #9 0x1b92c0e in execute_pass_list_1 ../../gcc/passes.c:2587
    #10 0x1b92ce8 in execute_pass_list(function*, opt_pass*) ../../gcc/passes.c:2597
    #11 0xce8eba in cgraph_node::expand() ../../gcc/cgraphunit.c:2139
    #12 0xcee454 in expand_all_functions ../../gcc/cgraphunit.c:2275
    #13 0xcee454 in symbol_table::compile() ../../gcc/cgraphunit.c:2624
    #14 0xcf89c6 in symbol_table::finalize_compilation_unit() ../../gcc/cgraphunit.c:2717
    #15 0x208763c in compile_file ../../gcc/toplev.c:480
    #16 0x74ee29 in do_compile ../../gcc/toplev.c:2132
    #17 0x74ee29 in toplev::main(int, char**) ../../gcc/toplev.c:2267
    #18 0x751cba in main ../../gcc/main.c:39
    #19 0x7fa721d2b6e4 in __libc_start_main (/lib64/libc.so.6+0x206e4)
    #20 0x751de8 in _start (/home/marxin/Programming/gcc/objdir/gcc/cc1+0x751de8)

Can be easily triggered with:

diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index a98e0e5e259..db14c8063c4 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -6783,6 +6783,7 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
 
   prev_stmt_info = NULL;
   tree vec_mask = NULL_TREE;
+  gcc_assert (loop_vinfo);
   vec_loop_masks *masks = &LOOP_VINFO_MASKS (loop_vinfo);
   for (j = 0; j < ncopies; j++)
     {
Comment 1 Richard Sandiford 2018-03-01 08:25:43 UTC
Mine.
Comment 2 Richard Sandiford 2018-03-02 09:47:14 UTC
Author: rsandifo
Date: Fri Mar  2 09:46:43 2018
New Revision: 258131

URL: https://gcc.gnu.org/viewcvs?rev=258131&root=gcc&view=rev
Log:
Avoid &LOOP_VINFO_MASKS for bb vectorisation (PR 84634)

We were computing &LOOP_VINFO_MASKS even for bb vectorisation,
which is UB.

2018-03-02  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
	PR tree-optimization/84634
	* tree-vect-stmts.c (vectorizable_store, vectorizable_load): Replace
	masks and masked_loop_p with a single loop_masks, making sure it's
	null for bb vectorization.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-vect-stmts.c
Comment 3 Richard Sandiford 2018-03-02 09:47:43 UTC
Fixed.