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

            Bug ID: 68310
           Summary: [6 Regression] Invalid read of size 1 in
                    options-save.c:3521
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
  Target Milestone: ---

Hello.

I've found could of valgrind errors related to options:

1) invalid read
==28904== Invalid read of size 1
==28904==    at 0x4C2BFC0: strcmp (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==28904==    by 0xA52C6F: cl_target_option_eq(cl_target_option const*,
cl_target_option const*) (options-save.c:3521)
==28904==    by 0xD11A4B: hash_table<cl_option_hasher,
xcallocator>::find_slot_with_hash(tree_node* const&, unsigned int,
insert_option) (hash-table.h:834)
==28904==    by 0xD09ACA: find_slot (hash-table.h:408)
==28904==    by 0xD09ACA: build_target_option_node(gcc_options*) (tree.c:12044)
==28904==    by 0xD6E130: ix86_valid_target_attribute_tree(tree_node*,
gcc_options*, gcc_options*) (i386.c:6169)
==28904==    by 0xD6E43F: get_builtin_code_for_version(tree_node*, tree_node**)
[clone .isra.124] (i386.c:36086)
==28904==    by 0xD6E818: ix86_compare_version_priority(tree_node*, tree_node*)
(i386.c:36258)
==28904==    by 0x6142D8: joust(z_candidate*, z_candidate*, bool, int) [clone
.part.35] (call.c:9306)
==28904==    by 0x6143A3: joust (call.c:9029)
==28904==    by 0x6143A3: tourney(z_candidate*, int) (call.c:9433)
==28904==    by 0x6198DA: perform_overload_resolution(tree_node*,
vec<tree_node*, va_gc, vl_embed> const*, z_candidate**, bool*, int)
(call.c:4023)
==28904==    by 0x61AC4E: build_new_function_call(tree_node*, vec<tree_node*,
va_gc, vl_embed>**, bool, int) (call.c:4096)
==28904==    by 0x6F23DA: finish_call_expr(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, bool, bool, int) (semantics.c:2410)
==28904==    by 0x6A22E8: cp_parser_postfix_expression(cp_parser*, bool, bool,
bool, bool, cp_id_kind*) (parser.c:6659)
==28904==    by 0x6A9C19: cp_parser_unary_expression(cp_parser*, cp_id_kind*,
bool, bool, bool) (parser.c:7723)
==28904==    by 0x6AA797: cp_parser_binary_expression(cp_parser*, bool, bool,
bool, cp_parser_prec, cp_id_kind*) (parser.c:8476)
==28904==    by 0x6AADBD: cp_parser_assignment_expression(cp_parser*,
cp_id_kind*, bool, bool) (parser.c:8740)
==28904==    by 0x6AB215: cp_parser_constant_expression(cp_parser*, bool,
bool*) (parser.c:8992)
==28904==    by 0x6BAD45: cp_parser_init_declarator(cp_parser*,
cp_decl_specifier_seq*, vec<deferred_access_check, va_gc, vl_embed>*, bool,
bool, int, bool*, tree_node**, bool, unsigned int*) (parser.c:18186)
==28904==    by 0x6BB7CA: cp_parser_simple_declaration(cp_parser*, bool,
tree_node**) (parser.c:12010)
==28904==    by 0x6BBBC3: cp_parser_block_declaration(cp_parser*, bool)
(parser.c:11882)
==28904==    by 0x6BC718: cp_parser_declaration_statement(cp_parser*)
(parser.c:11494)
==28904==    by 0x69E9A4: cp_parser_statement(cp_parser*, tree_node*, bool,
bool*, vec<tree_node*, va_heap, vl_ptr>*) (parser.c:10176)
==28904==    by 0x69EFC9: cp_parser_statement_seq_opt(cp_parser*, tree_node*)
(parser.c:10454)
==28904==    by 0x69F0EB: cp_parser_compound_statement(cp_parser*, tree_node*,
int, bool) (parser.c:10408)
==28904==    by 0x6B9BB0: cp_parser_function_body (parser.c:20223)
==28904==    by 0x6B9BB0:
cp_parser_ctor_initializer_opt_and_function_body(cp_parser*, bool)
(parser.c:20259)
==28904==    by 0x6BA5E0:
cp_parser_function_definition_after_declarator(cp_parser*, bool)
(parser.c:24875)
==28904==    by 0x6BB53A:
cp_parser_function_definition_from_specifiers_and_declarator (parser.c:24787)
==28904==    by 0x6BB53A: cp_parser_init_declarator(cp_parser*,
cp_decl_specifier_seq*, vec<deferred_access_check, va_gc, vl_embed>*, bool,
bool, int, bool*, tree_node**, bool, unsigned int*) (parser.c:18011)
==28904==    by 0x6BB7CA: cp_parser_simple_declaration(cp_parser*, bool,
tree_node**) (parser.c:12010)
==28904==    by 0x6BBBC3: cp_parser_block_declaration(cp_parser*, bool)
(parser.c:11882)
==28904==    by 0x696AA7: cp_parser_declaration(cp_parser*) (parser.c:11779)
==28904==    by 0x6C23DA: cp_parser_declaration_seq_opt(cp_parser*)
(parser.c:11658)
==28904==    by 0x6C2704: cp_parser_translation_unit (parser.c:4183)
==28904==    by 0x6C2704: c_parse_file() (parser.c:36531)
==28904==    by 0x78A0F2: c_common_parse_file() (c-opts.c:1064)
==28904==    by 0xB138DE: compile_file() (toplev.c:466)
==28904==    by 0x60A585: do_compile (toplev.c:1954)
==28904==    by 0x60A585: toplev::main(int, char**) (toplev.c:2061)
==28904==    by 0x11E145D: main (main.c:39)
==28904==  Address 0x65143b0 is 0 bytes inside a block of size 8 free'd
==28904==    at 0x4C2A7FB: free (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==28904==    by 0xD6E15F: ix86_valid_target_attribute_tree(tree_node*,
gcc_options*, gcc_options*) (i386.c:6177)
==28904==    by 0xD6E304: ix86_valid_target_attribute_p(tree_node*, tree_node*,
tree_node*, int) (i386.c:6225)
==28904==    by 0x74EFAE: handle_target_attribute(tree_node**, tree_node*,
tree_node*, int, bool*) (c-common.c:9894)
==28904==    by 0x7491CA: decl_attributes(tree_node**, tree_node*, int)
(attribs.c:548)
==28904==    by 0x67E23B: cplus_decl_attributes(tree_node**, tree_node*, int)
(decl2.c:1482)
==28904==    by 0x5F420A: grokfndecl(tree_node*, tree_node*, tree_node*,
tree_node*, tree_node*, tree_node*, int, overload_flags, int, cp_ref_qualifier,
tree_node*, int, int, int, int, bool, special_function_kind, bool, int,
tree_node*, tree_node**, unsigned int) (decl.c:8125)
==28904==    by 0x633F47: grokdeclarator(cp_declarator const*,
cp_decl_specifier_seq*, decl_context, int, tree_node**) (decl.c:11303)
==28904==    by 0x6357D6: start_decl(cp_declarator const*,
cp_decl_specifier_seq*, int, tree_node*, tree_node*, tree_node**) (decl.c:4762)
==28904==    by 0x6BAC4E: cp_parser_init_declarator(cp_parser*,
cp_decl_specifier_seq*, vec<deferred_access_check, va_gc, vl_embed>*, bool,
bool, int, bool*, tree_node**, bool, unsigned int*) (parser.c:18109)
==28904==    by 0x6BB7CA: cp_parser_simple_declaration(cp_parser*, bool,
tree_node**) (parser.c:12010)
==28904==    by 0x6BBBC3: cp_parser_block_declaration(cp_parser*, bool)
(parser.c:11882)
==28904==    by 0x696AA7: cp_parser_declaration(cp_parser*) (parser.c:11779)
==28904==    by 0x6C23DA: cp_parser_declaration_seq_opt(cp_parser*)
(parser.c:11658)
==28904==    by 0x6C2704: cp_parser_translation_unit (parser.c:4183)
==28904==    by 0x6C2704: c_parse_file() (parser.c:36531)
==28904==    by 0x78A0F2: c_common_parse_file() (c-opts.c:1064)
==28904==    by 0xB138DE: compile_file() (toplev.c:466)
==28904==    by 0x60A585: do_compile (toplev.c:1954)
==28904==    by 0x60A585: toplev::main(int, char**) (toplev.c:2061)
==28904==    by 0x11E145D: main (main.c:39)

command:
valgrind --leak-check=yes --num-callers=50 --trace-children=yes
--suppressions=/home/marxin/Programming/gcc2/gcc.supp --error-exitcode=111 -q 
/home/marxin/Programming/gcc2/objdir/gcc/testsuite/g++1/../../xg++
-B/home/marxin/Programming/gcc2/objdir/gcc/testsuite/g++1/../../
/home/marxin/Programming/gcc2/gcc/testsuite/g++.dg/ext/mv20.C
-fno-diagnostics-show-caret -fdiagnostics-color=never -nostdinc++
-I/home/marxin/Programming/gcc2/objdir/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu
-I/home/marxin/Programming/gcc2/objdir/x86_64-pc-linux-gnu/libstdc++-v3/include
-I/home/marxin/Programming/gcc2/libstdc++-v3/libsupc++
-I/home/marxin/Programming/gcc2/libstdc++-v3/include/backward
-I/home/marxin/Programming/gcc2/libstdc++-v3/testsuite/util -fmessage-length=0
-std=gnu++11 -O2 -fPIE -pie -march=x86-64
-L/home/marxin/Programming/gcc2/objdir/x86_64-pc-linux-gnu/./libstdc++-v3/src/.libs
-B/home/marxin/Programming/gcc2/objdir/x86_64-pc-linux-gnu/./libstdc++-v3/src/.libs
-L/home/marxin/Programming/gcc2/objdir/x86_64-pc-linux-gnu/./libstdc++-v3/src/.libs
-B/home/marxin/Programming/gcc2/objdir/x86_64-pc-linux-gnu/./libitm/
-L/home/marxin/Programming/gcc2/objdir/x86_64-pc-linux-gnu/./libitm/.libs -lm
-o ./mv20.exe

and 2)
==29068== 160 bytes in 1 blocks are definitely lost in loss record 640 of 752
==29068==    at 0x4C2AF1F: realloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==29068==    by 0x114D36C: xrealloc (xmalloc.c:180)
==29068==    by 0x10EB6EF: prune_options (opts-common.c:903)
==29068==    by 0x10EB6EF: decode_cmdline_options_to_array(unsigned int, char
const**, unsigned int, cl_decoded_option**, unsigned int*) (opts-common.c:795)
==29068==    by 0x679F95: parse_optimize_options(tree_node*, bool)
(c-common.c:10047)
==29068==    by 0x67A2A7: handle_optimize_attribute(tree_node**, tree_node*,
tree_node*, int, bool*) (c-common.c:10089)
==29068==    by 0x5F3C4A: decl_attributes(tree_node**, tree_node*, int)
(attribs.c:548)
==29068==    by 0x6074A1: start_function(c_declspecs*, c_declarator*,
tree_node*) (c-decl.c:8281)
==29068==    by 0x62F947: c_parser_declaration_or_fndef(c_parser*, bool, bool,
bool, bool, bool, tree_node**, vec<c_token, va_heap, vl_ptr>, tree_node*)
(c-parser.c:1947)
==29068==    by 0x6472BD: c_parser_external_declaration(c_parser*)
(c-parser.c:1435)
==29068==    by 0x647B79: c_parser_translation_unit (c-parser.c:1322)
==29068==    by 0x647B79: c_parse_file() (c-parser.c:17349)
==29068==    by 0x68B1D2: c_common_parse_file() (c-opts.c:1064)
==29068==    by 0xA13EBE: compile_file() (toplev.c:466)

command:
valgrind --leak-check=yes --trace-children=yes
--suppressions=/home/marxin/Programming/gcc2/gcc.supp --error-exitcode=111 -q 
/home/marxin/Programming/gcc2/objdir/gcc/xgcc
-B/home/marxin/Programming/gcc2/objdir/gcc/ -fno-diagnostics-show-caret
-fdiagnostics-color=never -O3 -g -w -c -o pr58332.o
/home/marxin/Programming/gcc2/gcc/testsuite/gcc.c-torture/compile/pr58332.c

I can fix these but a hind would be beneficial.
Thanks,
Martin

Reply via email to