diff mbox series

hash-table violation in gcc/fortran/trans-decl.c

Message ID 280d27b8-3f0e-67da-3e23-dc4df5c3abc5@suse.cz
State New
Headers show
Series hash-table violation in gcc/fortran/trans-decl.c | expand

Commit Message

Martin Liška Oct. 30, 2018, 10:07 a.m. UTC
On 10/29/18 12:04 PM, Martin Liška wrote:
> 2) gfc_find_module
> 
> $ ./xgcc -B. /home/marxin/Programming/gcc/gcc/testsuite/gfortran.dg/coarray/alloc_comp_2.f90 -fcoarray=single -fchecking=3
> hash table checking failed: equal operator returns true for a pair of values with a different hash valuef951: internal compiler error: in find_slot_with_hash, at hash-table.h:905
> 0x8e5e86 hash_table<module_hasher, xcallocator>::find_slot_with_hash(char const* const&, unsigned int, insert_option)
> 	/home/marxin/Programming/gcc/gcc/hash-table.h:905
> 0x8e2c2c gfc_find_module(char const*)
> 	/home/marxin/Programming/gcc/gcc/fortran/trans-decl.c:4865
> 0x8e4f42 gfc_generate_module_vars(gfc_namespace*)
> 	/home/marxin/Programming/gcc/gcc/fortran/trans-decl.c:5475
> 0x8b8d7e gfc_generate_module_code(gfc_namespace*)
> 	/home/marxin/Programming/gcc/gcc/fortran/trans.c:2190
> 0x868427 translate_all_program_units
> 	/home/marxin/Programming/gcc/gcc/fortran/parse.c:6112
> 0x868427 gfc_parse_file()
> 	/home/marxin/Programming/gcc/gcc/fortran/parse.c:6328
> 0x8b19cb gfc_be_parse_file
> 	/home/marxin/Programming/gcc/gcc/fortran/f95-lang.c:204

This one is real issue introduced in r216127, I'll post it to corresponding mailing list
after testing:


Martin

Comments

Trevor Saunders Oct. 31, 2018, 9:40 a.m. UTC | #1
On Tue, Oct 30, 2018 at 11:07:16AM +0100, Martin Li??ka wrote:
> On 10/29/18 12:04 PM, Martin Li??ka wrote:
> > 2) gfc_find_module
> > 
> > $ ./xgcc -B. /home/marxin/Programming/gcc/gcc/testsuite/gfortran.dg/coarray/alloc_comp_2.f90 -fcoarray=single -fchecking=3
> > hash table checking failed: equal operator returns true for a pair of values with a different hash valuef951: internal compiler error: in find_slot_with_hash, at hash-table.h:905
> > 0x8e5e86 hash_table<module_hasher, xcallocator>::find_slot_with_hash(char const* const&, unsigned int, insert_option)
> > 	/home/marxin/Programming/gcc/gcc/hash-table.h:905
> > 0x8e2c2c gfc_find_module(char const*)
> > 	/home/marxin/Programming/gcc/gcc/fortran/trans-decl.c:4865
> > 0x8e4f42 gfc_generate_module_vars(gfc_namespace*)
> > 	/home/marxin/Programming/gcc/gcc/fortran/trans-decl.c:5475
> > 0x8b8d7e gfc_generate_module_code(gfc_namespace*)
> > 	/home/marxin/Programming/gcc/gcc/fortran/trans.c:2190
> > 0x868427 translate_all_program_units
> > 	/home/marxin/Programming/gcc/gcc/fortran/parse.c:6112
> > 0x868427 gfc_parse_file()
> > 	/home/marxin/Programming/gcc/gcc/fortran/parse.c:6328
> > 0x8b19cb gfc_be_parse_file
> > 	/home/marxin/Programming/gcc/gcc/fortran/f95-lang.c:204
> 
> This one is real issue introduced in r216127, I'll post it to corresponding mailing list
> after testing:

Yeah, sorry and lgtm.  I wonder if we could make htab_hash_string take a
const char * to catch this sooner?

Trev

> 
> diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
> index 88f9f570725..e8da9e11d22 100644
> --- a/gcc/fortran/trans-decl.c
> +++ b/gcc/fortran/trans-decl.c
> @@ -4825,7 +4825,7 @@ struct module_hasher : ggc_ptr_hash<module_htab_entry>
>  {
>    typedef const char *compare_type;
>  
> -  static hashval_t hash (module_htab_entry *s) { return htab_hash_string (s); }
> +  static hashval_t hash (module_htab_entry *s) { return htab_hash_string (s->name); }
>    static bool
>    equal (module_htab_entry *a, const char *b)
>    {
> 
> Martin
Martin Liška Oct. 31, 2018, 9:57 a.m. UTC | #2
On 10/31/18 10:40 AM, Trevor Saunders wrote:
> On Tue, Oct 30, 2018 at 11:07:16AM +0100, Martin Li??ka wrote:
>> On 10/29/18 12:04 PM, Martin Li??ka wrote:
>>> 2) gfc_find_module
>>>
>>> $ ./xgcc -B. /home/marxin/Programming/gcc/gcc/testsuite/gfortran.dg/coarray/alloc_comp_2.f90 -fcoarray=single -fchecking=3
>>> hash table checking failed: equal operator returns true for a pair of values with a different hash valuef951: internal compiler error: in find_slot_with_hash, at hash-table.h:905
>>> 0x8e5e86 hash_table<module_hasher, xcallocator>::find_slot_with_hash(char const* const&, unsigned int, insert_option)
>>> 	/home/marxin/Programming/gcc/gcc/hash-table.h:905
>>> 0x8e2c2c gfc_find_module(char const*)
>>> 	/home/marxin/Programming/gcc/gcc/fortran/trans-decl.c:4865
>>> 0x8e4f42 gfc_generate_module_vars(gfc_namespace*)
>>> 	/home/marxin/Programming/gcc/gcc/fortran/trans-decl.c:5475
>>> 0x8b8d7e gfc_generate_module_code(gfc_namespace*)
>>> 	/home/marxin/Programming/gcc/gcc/fortran/trans.c:2190
>>> 0x868427 translate_all_program_units
>>> 	/home/marxin/Programming/gcc/gcc/fortran/parse.c:6112
>>> 0x868427 gfc_parse_file()
>>> 	/home/marxin/Programming/gcc/gcc/fortran/parse.c:6328
>>> 0x8b19cb gfc_be_parse_file
>>> 	/home/marxin/Programming/gcc/gcc/fortran/f95-lang.c:204
>>
>> This one is real issue introduced in r216127, I'll post it to corresponding mailing list
>> after testing:
> 
> Yeah, sorry and lgtm.  I wonder if we could make htab_hash_string take a
> const char * to catch this sooner?

That happens.

Exactly my thoughts! The issue is that old C-style htab in libiberty expects
void *, so I can come up with a specific const char * specialization that
we can leverage in gcc internally (read with C++).

Martin

> 
> Trev
> 
>>
>> diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
>> index 88f9f570725..e8da9e11d22 100644
>> --- a/gcc/fortran/trans-decl.c
>> +++ b/gcc/fortran/trans-decl.c
>> @@ -4825,7 +4825,7 @@ struct module_hasher : ggc_ptr_hash<module_htab_entry>
>>  {
>>    typedef const char *compare_type;
>>  
>> -  static hashval_t hash (module_htab_entry *s) { return htab_hash_string (s); }
>> +  static hashval_t hash (module_htab_entry *s) { return htab_hash_string (s->name); }
>>    static bool
>>    equal (module_htab_entry *a, const char *b)
>>    {
>>
>> Martin
diff mbox series

Patch

diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 88f9f570725..e8da9e11d22 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -4825,7 +4825,7 @@  struct module_hasher : ggc_ptr_hash<module_htab_entry>
 {
   typedef const char *compare_type;
 
-  static hashval_t hash (module_htab_entry *s) { return htab_hash_string (s); }
+  static hashval_t hash (module_htab_entry *s) { return htab_hash_string (s->name); }
   static bool
   equal (module_htab_entry *a, const char *b)
   {