Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Fwd: 5.8: LTO exposes some new issues
- X-seq: zsh-workers 46265
- From: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- To: Tomasz Kłoczko <kloczko.tomasz@xxxxxxxxx>
- Subject: Re: Fwd: 5.8: LTO exposes some new issues
- Date: Mon, 27 Jul 2020 13:09:16 +0200
- Cc: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- In-reply-to: <CABB28Cxo3HAvDf-MhpRyNVuK_TjNXpT+nhfWsSax=BK8+RTUhQ@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CABB28CwZXqp6AEr1Gnk_VFBOqeFNhPVnUnTJGTae=ePkqeMFkw@mail.gmail.com> <ca26b639-1878-4e72-9fad-a4037912038a@www.fastmail.com> <CAH+w=7aCiU6ZAeh1JwRg+b+A=WrFTz4_8st9_UXOy_VYZ9M77Q@mail.gmail.com> <CABB28CxSD5w-SY-iCVYuQ4kJfBpNJOWhpk4HOrS1DNPfMVztgw@mail.gmail.com> <CAH+w=7Z0oDO18u7uRVoOhjG0-0ydvi65zt2mMHD_wb636C9F1w@mail.gmail.com> <35bf1c7b-163f-4baf-9d5a-c1d7e72459ec@www.fastmail.com> <CABB28Cxo3HAvDf-MhpRyNVuK_TjNXpT+nhfWsSax=BK8+RTUhQ@mail.gmail.com>
- Sender: zsh-workers@xxxxxxx
On Mon, Jul 27, 2020 at 12:08 PM Tomasz Kłoczko
<kloczko.tomasz@xxxxxxxxx> 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.
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 */
Messages sorted by:
Reverse Date,
Date,
Thread,
Author