public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-10631] godump: Fix -fdump-go-spec= reproduceability issue [PR101407]
@ 2022-05-10  8:19 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2022-05-10  8:19 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:2c7087f46bb8c3f698cc475ece3786582bd34da0

commit r10-10631-g2c7087f46bb8c3f698cc475ece3786582bd34da0
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jul 14 10:22:50 2021 +0200

    godump: Fix -fdump-go-spec= reproduceability issue [PR101407]
    
    pot_dummy_types is a hash_set from whose traversal the code prints some type
    lines.  hash_set normally uses default_hash_traits which for pointer types
    (the hash set hashes const char *) uses pointer_hash which hashes the
    addresses of the pointers except of the least significant 3 bits.
    With address space randomization, that results in non-determinism in the
    -fdump-go-specs= generated file, each invocation can have different order of
    the lines emitted from pot_dummy_types traversal.
    
    This patch fixes it by hashing the string contents instead to make the
    hashes reproduceable.
    
    2021-07-14  Jakub Jelinek  <jakub@redhat.com>
    
            PR go/101407
            * godump.c (godump_str_hash): New type.
            (godump_container::pot_dummy_types): Use string_hash instead of
            ptr_hash in the hash_set.
    
    (cherry picked from commit 3be762c2ed79e36b9c8faaea2be04725c967a34e)

Diff:
---
 gcc/godump.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/godump.c b/gcc/godump.c
index a7cd7edf7a4..5e6fe07444b 100644
--- a/gcc/godump.c
+++ b/gcc/godump.c
@@ -56,6 +56,8 @@ static FILE *go_dump_file;
 
 static GTY(()) vec<tree, va_gc> *queue;
 
+struct godump_str_hash : string_hash, ggc_remove <const char *> {};
+
 /* A hash table of macros we have seen.  */
 
 static htab_t macro_hash;
@@ -543,7 +545,7 @@ public:
 
   /* Types which may potentially have to be defined as dummy
      types.  */
-  hash_set<const char *> pot_dummy_types;
+  hash_set<const char *, false, godump_str_hash> pot_dummy_types;
 
   /* Go keywords.  */
   htab_t keyword_hash;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-10  8:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10  8:19 [gcc r10-10631] godump: Fix -fdump-go-spec= reproduceability issue [PR101407] Jakub Jelinek

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).