From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 16674 invoked from network); 28 Jul 2020 11:51:55 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 28 Jul 2020 11:51:55 -0000 Received: (qmail 5482 invoked by alias); 28 Jul 2020 11:51:49 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: Sender: zsh-workers@zsh.org X-Seq: 46279 Received: (qmail 9079 invoked by uid 1010); 28 Jul 2020 11:51:49 -0000 X-Qmail-Scanner-Diagnostics: from wout4-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25884. spamassassin: 3.4.4. Clear:RC:0(64.147.123.20):SA:0(-2.6/5.0):. Processed in 0.731667 secs); 28 Jul 2020 11:51:49 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedriedvgdegfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkjghfofggtgfgsehtqhdttdertdejnecuhfhrohhmpeffrghnihgv lhcuufhhrghhrghfuceougdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgvqeenuc ggtffrrghtthgvrhhnpefhtdetfeehveeutdehuddtieefgeettedtjedtffehudeiieej leetteekudetheenucfkphepuddtledrieegrddugedurdeijeenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegurdhssegurghnihgvlhdrshhh rghhrghfrdhnrghmvg X-ME-Proxy: Date: Tue, 28 Jul 2020 11:51:11 +0000 From: Daniel Shahaf To: Roman Perepelitsa Cc: Peter Stephenson , Zsh hackers list Subject: Re: 5.8: LTO exposes some new issues Message-ID: <20200728115111.5afa1722@tarpaulin.shahaf.local2> In-Reply-To: References: <35bf1c7b-163f-4baf-9d5a-c1d7e72459ec@www.fastmail.com> <20200728075343.2cfb1ebf@tarpaulin.shahaf.local2> <727383568.664238.1595924724485@mail2.virginmedia.com> <20200728111956.21617dde@tarpaulin.shahaf.local2> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Roman Perepelitsa wrote on Tue, 28 Jul 2020 13:31 +0200: > On Tue, Jul 28, 2020 at 1:20 PM Daniel Shahaf wr= ote: > > > > Roman Perepelitsa wrote on Tue, 28 Jul 2020 12:52 +0200: =20 > > > > > > How about this? The diff is a bit larger but the code is fairly > > > straightforward. Only hashtable.c has access to internal fields, just > > > like before the patch. > > > > > > In a nutshell, struct hashtable has only public data members. Within > > > hashtable.c there is struct hashtableimpl, which has struct hashtable > > > as the first data member. C allows casting a pointer to a struct to a > > > pointer to its first data member and back without violating aliasing > > > rules. Thus hashtable.c can cast struct hashtable* to struct > > > hashtableimpl* in order to get access to internal fields. =20 > > > > Thanks, that addresses the previous point, but unfortunately it creates > > another problem: people who read the .h file are liable to declare > > local variables of type 'struct hashtable', or memcpy() them around, > > and in either case, once such a variable gets to hashtable.c and the > > private members are accessed, we'll get out-of-bounds reads. =20 >=20 > This problem exists in the current version of the code, too. The patch > addresses one problem -- it removes undefined behavior due to ODR > violation. If you want, I can extend the patch so that it also > addresses the second problem you've identified although it might be > betted done in a separate patch given that it's independent from the > first. Whatever you think best. In general, if in doubt I'd err on the side of splitting. Thanks again for looking into this. =E2=98=BA Daniel