Bug 71158 - ICE in tree_to_uhwi with -fsanitize=address
Summary: ICE in tree_to_uhwi with -fsanitize=address
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: sanitizer (show other bugs)
Version: 7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
: 71378 (view as bug list)
Depends on:
Blocks: C++VLA
  Show dependency treegraph
 
Reported: 2016-05-17 07:07 UTC by Vittorio Zecca
Modified: 2017-05-06 17:38 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.9.3, 5.3.0, 6.1.0
Last reconfirmed: 2016-05-17 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vittorio Zecca 2016-05-17 07:07:40 UTC
Compiling the following with
g++ -fsanitize=address 
int main()
{
int offset=1;
char buf[offset]="";
}

I get the following:

p.C:5:1: internal compiler error: in tree_to_uhwi, at tree.c:7345
 }
 ^
0xff3be2 tree_to_uhwi(tree_node const*)
	/home/vitti/gcc7/gcc/tree.c:7345
0xd8005e asan_add_global
	/home/vitti/gcc7/gcc/asan.c:2268
0xd80a74 add_string_csts(constant_descriptor_tree**, asan_add_string_csts_data*)
	/home/vitti/gcc7/gcc/asan.c:2478
0xd80fca void hash_table<tree_descriptor_hasher, xcallocator>::traverse_noresize<asan_add_string_csts_data*, &(add_string_csts(constant_descriptor_tree**, asan_add_string_csts_data*))>(asan_add_string_csts_data*)
	/home/vitti/gcc7/gcc/hash-table.h:950
0xd80fca void hash_table<tree_descriptor_hasher, xcallocator>::traverse<asan_add_string_csts_data*, &(add_string_csts(constant_descriptor_tree**, asan_add_string_csts_data*))>(asan_add_string_csts_data*)
	/home/vitti/gcc7/gcc/hash-table.h:972
0xd80fca asan_finish_file()
	/home/vitti/gcc7/gcc/asan.c:2550
Comment 1 Richard Biener 2016-05-17 08:25:05 UTC
Confirmed.
Comment 2 Jakub Jelinek 2016-05-17 08:34:02 UTC
That is a C++ FE bug.  If it really wants to support initializing of VLAs (C rejects this), it should do it correctly.
Here it creates a STRING_CST with a VLA type, which during expansion is pushed into constant pool.  But, ASAN rightly assumes that constant pool objects have constant sizes.
Comment 3 Martin Sebor 2016-05-17 15:12:01 UTC
There are problems in this area.  See also bug 69487 and bug 58646.
Comment 4 Jakub Jelinek 2016-06-03 11:30:46 UTC
*** Bug 71378 has been marked as a duplicate of this bug. ***
Comment 5 Vittorio Zecca 2017-05-06 17:38:33 UTC
Fixed in 7.1.0