public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: gcc-patches@gcc.gnu.org
Cc: Nathan Sidwell <nathan@acm.org>, Jason Merrill <jason@redhat.com>,
	Jakub Jelinek <jakub@redhat.com>,
	Paul Richard Thomas <paul.richard.thomas@gmail.com>,
	Martin Jambor <mjambor@suse.cz>,
	Marek Polacek <polacek@redhat.com>
Subject: Re: hash-table violation in gcc/cp/pt.c
Date: Tue, 30 Oct 2018 11:21:00 -0000	[thread overview]
Message-ID: <ea557c4e-651c-454e-4ee4-80d211da5223@suse.cz> (raw)
In-Reply-To: <7ef9e4b3-27db-ff50-2b96-e7ed64dd85cc@suse.cz>

On 10/30/18 11:25 AM, Martin Liška wrote:
> On 10/29/18 12:04 PM, Martin Liška wrote:
>> 3) lookup_template_class_1
>>
>> $ ./xg++ -B. /home/marxin/Programming/gcc/gcc/testsuite/g++.dg/template/ttp23.C -c -fchecking=3
>> hash table checking failed: equal operator returns true for a pair of values with a different hash value/home/marxin/Programming/gcc/gcc/testsuite/g++.dg/template/ttp23.C: In instantiation of ‘struct B<A>’:
>> /home/marxin/Programming/gcc/gcc/testsuite/g++.dg/template/ttp23.C:15:8:   required from here
>> /home/marxin/Programming/gcc/gcc/testsuite/g++.dg/template/ttp23.C:8:17: internal compiler error: in find_slot_with_hash, at hash-table.h:905
>>     8 |     friend bool foo (const B<Q>& a);
>>       |                 ^~~
>> 0xa265a4 hash_table<spec_hasher, xcallocator>::find_slot_with_hash(spec_entry* const&, unsigned int, insert_option)
>> 	/home/marxin/Programming/gcc/gcc/hash-table.h:905
>> 0xa042ce lookup_template_class_1
>> 	/home/marxin/Programming/gcc/gcc/cp/pt.c:9629
>> 0xa042ce lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*, int, int)
>> 	/home/marxin/Programming/gcc/gcc/cp/pt.c:9674
>> 0xa03670 tsubst_aggr_type
>> 	/home/marxin/Programming/gcc/gcc/cp/pt.c:12679
>> 0x9fefcd tsubst(tree_node*, tree_node*, int, tree_node*)
>> 	/home/marxin/Programming/gcc/gcc/cp/pt.c:14294
>> 0x9fe1a9 tsubst(tree_node*, tree_node*, int, tree_node*)
>> 	/home/marxin/Programming/gcc/gcc/cp/pt.c:14285
>> 0xa0d8bd tsubst_arg_types
>> 	/home/marxin/Programming/gcc/gcc/cp/pt.c:13891
>> 0xa0dc24 tsubst_function_type
>> 	/home/marxin/Programming/gcc/gcc/cp/pt.c:14032
>> 0x9fe790 tsubst(tree_node*, tree_node*, int, tree_node*)
>> 	/home/marxin/Programming/gcc/gcc/cp/pt.c:14769
>> 0x9f2c7c tsubst_function_decl
>> 	/home/marxin/Programming/gcc/gcc/cp/pt.c:12921
>> 0xa02d27 tsubst_template_decl
>> 	/home/marxin/Programming/gcc/gcc/cp/pt.c:13214
>> 0x9f4416 tsubst_decl
>> 	/home/marxin/Programming/gcc/gcc/cp/pt.c:13316
>> 0x9ff0ca tsubst(tree_node*, tree_node*, int, tree_node*)
>> 	/home/marxin/Programming/gcc/gcc/cp/pt.c:14212
>> 0xa1dfd0 tsubst_friend_function
>> 	/home/marxin/Programming/gcc/gcc/cp/pt.c:10310
>> 0xa1dfd0 instantiate_class_template_1
>> 	/home/marxin/Programming/gcc/gcc/cp/pt.c:11359
>> 0xa1dfd0 instantiate_class_template(tree_node*)
>> 	/home/marxin/Programming/gcc/gcc/cp/pt.c:11424
>> 0xa66b22 complete_type(tree_node*)
>> 	/home/marxin/Programming/gcc/gcc/cp/typeck.c:138
>> 0x9023c7 start_decl_1(tree_node*, bool)
>> 	/home/marxin/Programming/gcc/gcc/cp/decl.c:5278
>> 0x92a15f start_decl(cp_declarator const*, cp_decl_specifier_seq*, int, tree_node*, tree_node*, tree_node**)
>> 	/home/marxin/Programming/gcc/gcc/cp/decl.c:5241
>> 0x9c1944 cp_parser_init_declarator
>> 	/home/marxin/Programming/gcc/gcc/cp/parser.c:19750
> 
> This one is about inconsistency between:
> 
> /* Returns a hash for a template TMPL and template arguments ARGS.  */
> 
> static hashval_t
> hash_tmpl_and_args (tree tmpl, tree args)
> {
>   hashval_t val = iterative_hash_object (DECL_UID (tmpl), 0);
>   return iterative_hash_template_arg (args, val);
> }
> 
> iterative_hash_template_arg is problematic, differs from:
> bool
> spec_hasher::equal (spec_entry *e1, spec_entry *e2)
> {
>   int equal;
> 
>   ++comparing_specializations;
>   equal = (e1->tmpl == e2->tmpl
> 	   && comp_template_args (e1->args, e2->args));
> ...
> 
> where comp_template_args (e1->args, e2->args) returns true, but
> iterative_hash_template_arg values are different.
> 
> Can please some C++ maintainer take a look?
> 
> Thanks,
> Martin
> 

The same spec_hasher type is also involved in 4)

0xa265a4 hash_table<spec_hasher, xcallocator>::find_slot_with_hash(spec_entry* const&, unsigned int, insert_option)
	/home/marxin/Programming/gcc/gcc/hash-table.h:905
0x9e35e6 register_specialization
	/home/marxin/Programming/gcc/gcc/cp/pt.c:1534
0xa22ac3 check_explicit_specialization(tree_node*, tree_node*, int, int, tree_node*)
	/home/marxin/Programming/gcc/gcc/cp/pt.c:3243
0x91552d grokfndecl
	/home/marxin/Programming/gcc/gcc/cp/decl.c:9106
...

Martin

  reply	other threads:[~2018-10-30 10:32 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-29 12:02 [PATCH][RFC] Sanitize equals and hash functions in hash-tables Martin Liška
2018-10-29 14:28 ` Alexander Monakov
2018-10-29 15:56   ` Martin Liška
2018-10-30 10:32     ` Jakub Jelinek
2018-10-30 14:17       ` Martin Liška
2018-11-07 22:24         ` Jeff Law
2018-11-07 22:44           ` Jakub Jelinek
2018-11-08  8:56           ` Martin Liška
2019-05-13  7:42             ` Martin Liška
2019-05-20 17:26               ` Jason Merrill
2019-05-20 22:07               ` Jeff Law
2019-05-21  9:38                 ` Richard Biener
2019-05-21 11:02                   ` Martin Liška
2019-05-21 11:52                     ` Richard Biener
2019-05-22  9:13                       ` Martin Liška
2019-05-31 13:23                         ` Richard Biener
2019-05-31 13:35                           ` Martin Liška
2019-05-31 22:10                         ` Jeff Law
2019-06-03 13:35                           ` Martin Liška
2019-06-07  8:57                             ` Richard Biener
2019-06-07 12:04                               ` Martin Liška
2019-06-07 12:09                                 ` Richard Biener
2019-06-07 12:13                                   ` Martin Liška
2019-06-07 14:48                                     ` Martin Sebor
2019-06-07 21:43                                     ` Jason Merrill
2019-06-10  7:08                                       ` Martin Liška
2019-06-10 18:22                                         ` Jason Merrill
2019-06-11  7:41                                           ` Martin Liška
2019-06-11 12:28                                             ` Jason Merrill
2019-06-11 13:16                                               ` Martin Liška
2019-06-11 19:02                                                 ` Jason Merrill
2019-06-12  7:59                                                   ` Richard Biener
2019-06-12  8:02                                                     ` Martin Liška
2019-06-12  9:15                                                       ` Martin Liška
2019-06-12  9:41                                                         ` Richard Biener
2019-06-12 11:45                                                           ` Martin Liška
2019-06-12 12:50                                                             ` Richard Biener
2019-06-12 13:05                                                               ` Martin Liška
2019-06-23 23:08                                 ` Ian Lance Taylor
2019-06-24 12:29                                   ` Richard Biener
2019-06-24 13:51                                     ` Martin Liška
2019-06-24 14:10                                       ` Richard Biener
2019-06-25 10:25                                         ` Martin Liška
2019-06-25 11:59                                           ` Martin Liška
2019-06-25 14:23                                           ` Richard Biener
2018-10-30 10:25 ` hash-table violation in cselib.c Martin Liška
2018-11-01 11:57   ` Martin Liška
2018-10-30 10:46 ` hash-table violation in gcc/fortran/trans-decl.c Martin Liška
2018-10-31 10:00   ` Trevor Saunders
2018-10-31 10:18     ` Martin Liška
2018-10-30 11:07 ` hash-table violation in gcc/cp/pt.c Martin Liška
2018-10-30 11:21   ` Martin Liška [this message]
2018-11-01 12:06     ` Martin Liška

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ea557c4e-651c-454e-4ee4-80d211da5223@suse.cz \
    --to=mliska@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jason@redhat.com \
    --cc=mjambor@suse.cz \
    --cc=nathan@acm.org \
    --cc=paul.richard.thomas@gmail.com \
    --cc=polacek@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).