Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wBzQE-001Yyx-2W for pgsql-hackers@arkaria.postgresql.org; Sun, 12 Apr 2026 18:20:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wBzQC-0030Z4-0q for pgsql-hackers@arkaria.postgresql.org; Sun, 12 Apr 2026 18:20:37 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wBzQB-0030Yw-3A for pgsql-hackers@lists.postgresql.org; Sun, 12 Apr 2026 18:20:36 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wBzQA-00000000ftg-3x5O for pgsql-hackers@postgresql.org; Sun, 12 Apr 2026 18:20:36 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 63CIKV1E343363; Sun, 12 Apr 2026 14:20:31 -0400 From: Tom Lane To: Lukas Fittl cc: Haibo Yan , Andres Freund , pgsql-hackers , David Geier Subject: Re: Reduce timing overhead of EXPLAIN ANALYZE using rdtsc? In-reply-to: References: <6wzsdvie5fvg427qti6icezycculhdr3vaykznbg27vtzzxa3p@hfk5m7cs5m4k> <26pttea74dz5gvsplaa4qsrwuytrza6g2mieqb7wxi4nnwb3cp@7uhq7zkfm6me> Comments: In-reply-to Lukas Fittl message dated "Sun, 12 Apr 2026 09:38:15 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <343361.1776018031.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 12 Apr 2026 14:20:31 -0400 Message-ID: <343362.1776018031@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Lukas Fittl writes: > FWIW, for archive's sake, drongo is green again now, thanks to commit > 7fc36c5db550 (Avoid CPUID 0x15/0x16 for Hypervisor TSC frequency). drongo may be happy, but Coverity is not: 166 uint64 loop_count; 167 = 168 loop_count =3D test_timing(test_duration, TIMING_CLOCK_SOURCE_SYS= TEM, false); >>> CID 1691465: Incorrect expression (DIVIDE_BY_ZERO) >>> In function call "output", division by expression "loop_count" whi= ch may be zero has undefined behavior. 169 output(loop_count); AFAICS it's correct to complain. test_timing() visibly can return zero, but of the three places where test_timing() is followed by output() only one has a defense against that. regards, tom lane