zsh-workers
 help / color / mirror / code / Atom feed
From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: "Tomasz Kłoczko" <kloczko.tomasz@gmail.com>
Cc: Daniel Shahaf <d.s@daniel.shahaf.name>,
	Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Fwd: 5.8: LTO exposes some new issues
Date: Mon, 27 Jul 2020 13:09:16 +0200	[thread overview]
Message-ID: <CAN=4vMoe4z=QqGK6FOxqo4FBYXj7oOU2NQJNk58iqtXR9agk1Q@mail.gmail.com> (raw)
In-Reply-To: <CABB28Cxo3HAvDf-MhpRyNVuK_TjNXpT+nhfWsSax=BK8+RTUhQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 715 bytes --]

On Mon, Jul 27, 2020 at 12:08 PM Tomasz Kłoczko
<kloczko.tomasz@gmail.com> wrote:
>
> For someone who is maintaining that code, making such a decision should be
> way easier.

This statement is true but it's too general to be of any use here. Of
course making changes is easier for maintainers than for outsiders.
This doesn't mean that all changes (and this change in particular)
must be made by maintainers.

Anyway, I took a look at it. The problem is that `struct hashtable`
has a different set of members in different translation units. This is
undefined behavior whether LTO is used or not. Undefined behavior is
bad, so it would be nice to have this bug fixed. A patch is attached.

Roman.

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 2182 bytes --]

diff --git a/Src/hashtable.c b/Src/hashtable.c
index e210ddeca..fa9d31052 100644
--- a/Src/hashtable.c
+++ b/Src/hashtable.c
@@ -28,23 +28,6 @@
  */
 
 #include "../config.h"
-
-#ifdef ZSH_HASH_DEBUG
-# define HASHTABLE_DEBUG_MEMBERS \
-    /* Members of struct hashtable used for debugging hash tables */ \
-    HashTable next, last;	/* linked list of all hash tables           */ \
-    char *tablename;		/* string containing name of the hash table */ \
-    PrintTableStats printinfo;	/* pointer to function to print table stats */
-#else /* !ZSH_HASH_DEBUG */
-# define HASHTABLE_DEBUG_MEMBERS
-#endif /* !ZSH_HASH_DEBUG */
-
-#define HASHTABLE_INTERNAL_MEMBERS \
-    ScanStatus scan;		/* status of a scan over this hashtable     */ \
-    HASHTABLE_DEBUG_MEMBERS
-
-typedef struct scanstatus *ScanStatus;
-
 #include "zsh.mdh"
 #include "hashtable.pro"
 
diff --git a/Src/zsh.h b/Src/zsh.h
index c48be4ffd..f9caa2f6e 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1182,6 +1182,18 @@ typedef void (*PrintTableStats) _((HashTable));
 
 /* hash table for standard open hashing */
 
+#ifdef ZSH_HASH_DEBUG
+# define HASHTABLE_DEBUG_MEMBERS \
+    /* Members of struct hashtable used for debugging hash tables */ \
+    HashTable next, last;	/* linked list of all hash tables           */ \
+    char *tablename;		/* string containing name of the hash table */ \
+    PrintTableStats printinfo;	/* pointer to function to print table stats */
+#else /* !ZSH_HASH_DEBUG */
+# define HASHTABLE_DEBUG_MEMBERS
+#endif /* !ZSH_HASH_DEBUG */
+
+typedef struct scanstatus *ScanStatus;
+
 struct hashtable {
     /* HASHTABLE DATA */
     int hsize;			/* size of nodes[]  (number of hash values)   */
@@ -1205,9 +1217,9 @@ struct hashtable {
     ScanFunc printnode;		/* pointer to function to print a node        */
     ScanTabFunc scantab;	/* pointer to function to scan table          */
 
-#ifdef HASHTABLE_INTERNAL_MEMBERS
-    HASHTABLE_INTERNAL_MEMBERS	/* internal use in hashtable.c                */
-#endif
+    /* HASHTABLE INTERNAL MEMBERS */
+    ScanStatus scan;		/* status of a scan over this hashtable       */
+    HASHTABLE_DEBUG_MEMBERS
 };
 
 /* generic hash table node */

  reply	other threads:[~2020-07-27 11:10 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-21 23:41 Tomasz Kłoczko
2020-07-22  5:59 ` Daniel Shahaf
2020-07-25 17:43   ` Bart Schaefer
     [not found]     ` <CABB28CxSD5w-SY-iCVYuQ4kJfBpNJOWhpk4HOrS1DNPfMVztgw@mail.gmail.com>
2020-07-25 20:05       ` Fwd: " Bart Schaefer
2020-07-27  2:12         ` Daniel Shahaf
2020-07-27 10:07           ` Tomasz Kłoczko
2020-07-27 11:09             ` Roman Perepelitsa [this message]
2020-07-27 12:19               ` Roman Perepelitsa
2020-07-27 12:46                 ` Tomasz Kłoczko
2020-07-27 14:13                   ` Roman Perepelitsa
2020-07-27 14:19                   ` Roman Perepelitsa
2020-07-28  8:09                     ` Daniel Shahaf
2020-07-28 10:55                     ` Fwd: " Roman Perepelitsa
2020-07-28  8:19                   ` Daniel Shahaf
2020-07-28  7:53                 ` Daniel Shahaf
2020-07-28  8:25                   ` Peter Stephenson
2020-07-28 10:52                     ` Roman Perepelitsa
2020-07-28 11:19                       ` Daniel Shahaf
2020-07-28 11:31                         ` Roman Perepelitsa
2020-07-28 11:51                           ` Daniel Shahaf

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='CAN=4vMoe4z=QqGK6FOxqo4FBYXj7oOU2NQJNk58iqtXR9agk1Q@mail.gmail.com' \
    --to=roman.perepelitsa@gmail.com \
    --cc=d.s@daniel.shahaf.name \
    --cc=kloczko.tomasz@gmail.com \
    --cc=zsh-workers@zsh.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).