From patchwork Thu Jan 31 17:59:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Braun X-Patchwork-Id: 10791079 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F38BB13A4 for ; Thu, 31 Jan 2019 17:59:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5C4430FA0 for ; Thu, 31 Jan 2019 17:59:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D680F30FA3; Thu, 31 Jan 2019 17:59:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C727E30FA0 for ; Thu, 31 Jan 2019 17:59:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727903AbfAaR7V (ORCPT ); Thu, 31 Jan 2019 12:59:21 -0500 Received: from wp156.webpack.hosteurope.de ([80.237.132.163]:37830 "EHLO wp156.webpack.hosteurope.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727838AbfAaR7V (ORCPT ); Thu, 31 Jan 2019 12:59:21 -0500 Received: from app04-neu.ox.hosteurope.de ([92.51.170.138]); authenticated by wp156.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.0:ECDHE_RSA_AES_256_CBC_SHA1:256) id 1gpGcP-00048T-Mo; Thu, 31 Jan 2019 18:59:17 +0100 Date: Thu, 31 Jan 2019 18:59:17 +0100 (CET) From: Thomas Braun To: Junio C Hamano , git@vger.kernel.org Cc: Martin Koegler , =?utf-8?q?Torsten_B=C3=B6gers?= =?utf-8?q?hausen?= Message-ID: <994568940.109648.1548957557643@ox.hosteurope.de> In-Reply-To: References: Subject: mk/use-size-t-in-zlib [was: Re: What's cooking in git.git (Jan 2019, #05; Tue, 29)] MIME-Version: 1.0 X-Priority: 3 Importance: Medium X-Mailer: Open-Xchange Mailer v7.8.4-Rev48 X-Originating-Client: open-xchange-appsuite X-bounce-key: webpack.hosteurope.de;thomas.braun@virtuell-zuhause.de;1548957560;c0c4b272; X-HE-SMSGID: 1gpGcP-00048T-Mo Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP > Junio C Hamano hat am 29. Januar 2019 um 23:15 geschrieben: [...] > * mk/use-size-t-in-zlib (2018-10-15) 1 commit > - zlib.c: use size_t for size > > The wrapper to call into zlib followed our long tradition to use > "unsigned long" for sizes of regions in memory, which have been > updated to use "size_t". > I've started playing around with the patch from Thorsten [1] for getting unsigned long replaced in more places so that you can commit large files on platforms like Windows there unsigned long is 32-bit even on 64-bit OSes. And the first thing which bugs out when I do a quick test with committing a large file and fsck the repo is in zlib.c: if (s->z.total_out != s->total_out + bytes_produced) BUG("total_out mismatch"); here s->z.total_out is an unsigned long and s->total_out is size_t and this triggers the BUG message once the unsigned long wraps. There is even an FAQ entry for zlib at [2] which warns about that potential issue. So I would think that something like ----------->8 -----------8< would make the patch [3] more complete IMHO. Another potential issue in that patch is that the signature change in git_deflate_bound forces size to unsigned long on the call to deflateBound (for newer zlib versions) and if that conversion is not faithful this will certainly not work. Just my 2cents I'm not vetoing anything here, Thomas [1]: http://public-inbox.org/git/20181120050456.16715-1-tboegi@web.de/ [2]: http://www.zlib.net/zlib_faq.html#faq32 [3]: http://public-inbox.org/git/20181012204229.11890-1-tboegi@web.de/ diff --git a/zlib.c b/zlib.c index 197a1acc7b..9cc6421eba 100644 --- a/zlib.c +++ b/zlib.c @@ -51,13 +51,9 @@ static void zlib_post_call(git_zstream *s) bytes_consumed = s->z.next_in - s->next_in; bytes_produced = s->z.next_out - s->next_out; - if (s->z.total_out != s->total_out + bytes_produced) - BUG("total_out mismatch"); - if (s->z.total_in != s->total_in + bytes_consumed) - BUG("total_in mismatch"); - s->total_out = s->z.total_out; - s->total_in = s->z.total_in; + s->total_out += bytes_produced; + s->total_in += bytes_consumed; s->next_in = s->z.next_in; s->next_out = s->z.next_out; s->avail_in -= bytes_consumed;