From patchwork Thu Sep 27 22:24:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramsay Jones X-Patchwork-Id: 10618673 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 3B35A15A6 for ; Thu, 27 Sep 2018 22:24:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C3AD2B970 for ; Thu, 27 Sep 2018 22:24:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1FBA72B979; Thu, 27 Sep 2018 22:24:46 +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 A0DE42B970 for ; Thu, 27 Sep 2018 22:24:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726024AbeI1EpN (ORCPT ); Fri, 28 Sep 2018 00:45:13 -0400 Received: from avasout07.plus.net ([84.93.230.235]:36557 "EHLO avasout07.plus.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725972AbeI1EpN (ORCPT ); Fri, 28 Sep 2018 00:45:13 -0400 Received: from [10.0.2.15] ([80.189.70.183]) by smtp with ESMTPA id 5ei9gWnZUjlDz5eiAg7YGY; Thu, 27 Sep 2018 23:24:43 +0100 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.3 cv=GrdsBH9C c=1 sm=1 tr=0 a=6SF67mWK+VR8hB1Kjo6y2g==:117 a=6SF67mWK+VR8hB1Kjo6y2g==:17 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=UR-nH_2hBq7ztSmMy8wA:9 a=QEXdDO2ut3YA:10 a=yJM6EZoI5SlJf8ks9Ge_:22 X-AUTH: ramsayjones@:2500 To: Ben Peart Cc: Junio C Hamano , GIT Mailing-list From: Ramsay Jones Subject: [PATCH] read-cache: fix division by zero core-dump Message-ID: <476b5678-41b2-d2f8-1890-ba315354ebc0@ramsayjones.plus.com> Date: Thu, 27 Sep 2018 23:24:39 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Language: en-GB X-CMAE-Envelope: MS4wfJHRj+why3N5c2ur6VR7V3mxAi04NIrwnfPvbZ81HUfWPHBy5Qg/Uok3S3Bq1WtWXVymlFqnMzWSLvfk75/K/SVtggssx6/GU+/0H6evMY+mwIs+nxUW 4aTggppnc5YPrxbZI+Gw8GhPTIaDpYb1DiiOMbb1ahvL/TA/pF7Nbqh5FWq76Vh2II5XPf8hbwSoNg== Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP commit 225df8a468 ("ieot: add Index Entry Offset Table (IEOT) extension", 2018-09-26) added a 'DIV_ROUND_UP(entries, ieot_blocks) expression, where ieot_blocks was set to zero for a single cpu platform. This caused an SIGFPE and a core dump in practically every test in the test-suite, until test t4056-diff-order.sh, which then went into an infinite loop! Signed-off-by: Ramsay Jones --- Hi Ben, Could you please squash this into the relevant commits on your 'bp/read-cache-parallel' branch. (The first hunk fixes a sparse warning about using an integer as a NULL pointer). Thanks! ATB, Ramsay Jones read-cache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/read-cache.c b/read-cache.c index 6755d58877..40f096f70a 100644 --- a/read-cache.c +++ b/read-cache.c @@ -2141,7 +2141,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist) size_t extension_offset = 0; #ifndef NO_PTHREADS int nr_threads, cpus; - struct index_entry_offset_table *ieot = 0; + struct index_entry_offset_table *ieot = NULL; #endif if (istate->initialized) @@ -2771,7 +2771,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile, if (ieot_blocks < 1) ieot_blocks = 1; cpus = online_cpus(); - if (ieot_blocks > cpus - 1) + if (cpus > 1 && ieot_blocks > cpus - 1) ieot_blocks = cpus - 1; } else { ieot_blocks = nr;