Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iqkLC-00040W-Nz for pgsql-hackers@arkaria.postgresql.org; Sun, 12 Jan 2020 21:00:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iqkLA-00071k-Rb for pgsql-hackers@arkaria.postgresql.org; Sun, 12 Jan 2020 21:00:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iqkLA-00071d-AU for pgsql-hackers@lists.postgresql.org; Sun, 12 Jan 2020 21:00:08 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iqkL6-0003rl-Oe for pgsql-hackers@postgresql.org; Sun, 12 Jan 2020 21:00:07 +0000 Received: by mail-pl1-x644.google.com with SMTP id g6so3015024plp.6 for ; Sun, 12 Jan 2020 13:00:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=e5Ws9NPrFYLTIRAj/S1+6L9Guec6Y7ADXvarsOSCROc=; b=d758S+KZmKeVmhH3ORwhsby+sRDIbfTKfAWpbaiY92OU+by9gVwXjoIDdWTkXUiXNW G3XOnZcqv21NE+v3i2BU4Gk4v/Ho8O+ObVEkt/ko0oW9NG7FXNlhhnd+lZl9mFGAdIw2 2I4odHnqTwjUhvNEYa35MtPz9lvf6e0h5++RM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=e5Ws9NPrFYLTIRAj/S1+6L9Guec6Y7ADXvarsOSCROc=; b=N/cTdsPnQBYd3aPcFJasva6jLoPi91yMGpQSWlXgqFatpMjp0M3UXf7ofsFF1MPmvy H0cb+wNwz6xurrjT4cKoQPSuj4hNhGoXTXUpYtC3GMC87S6Kpmf4JbXXlntW512K/ue4 DOnO7Wg5qYXcWzaBN4WDum0fsqGtc4mhM8zSc9Cof1pl5HJJalGN69+Y2GCn9puXXdwr LlWv3lWZHXvvKycPw14qgxVLtySRtffGKIL06Mk+XoZUunqgCGhgOF5G/6wXwyka+B6B /wyE6w9YkrULRxKZRt7ds9zcBrClHOnwzIJ8RnYRNWiI4VWmr+yQmdPz3jECDdOtaOuj 2xRw== X-Gm-Message-State: APjAAAWtZ3pGyz3rAtx/RXjcWxuSVAd9Fy9CVUOiRxkW7qu9Nj11FQDN cFxMxWpKdUOwtvHgj+Jr4aq2mA== X-Google-Smtp-Source: APXvYqywDgqT516OVodUnGZZWrXW3HthVwkxAKsG2IBWvz9hO4fG7BSOPs99IX8EcRtInewRTfAWNw== X-Received: by 2002:a17:902:9a8f:: with SMTP id w15mr10873365plp.149.1578862802517; Sun, 12 Jan 2020 13:00:02 -0800 (PST) Received: from rfd.leadboat.com (108-233-125-46.lightspeed.sntcca.sbcglobal.net. [108.233.125.46]) by smtp.gmail.com with ESMTPSA id d14sm10675792pjz.12.2020.01.12.13.00.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Jan 2020 13:00:01 -0800 (PST) Date: Sun, 12 Jan 2020 12:59:59 -0800 From: Noah Misch To: Thomas Munro Cc: Tom Lane , Pg Hackers Subject: Re: Consolidate 'unique array values' logic into a reusable function? Message-ID: <20200112205959.GA2629881@rfd.leadboat.com> References: <22244.1470585142@sss.pgh.pa.us> <20191229070221.GA13873@gust.leadboat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, Jan 08, 2020 at 02:49:48PM +1300, Thomas Munro wrote: > On Sun, Dec 29, 2019 at 8:02 PM Noah Misch wrote: > > ==00:00:00:28.322 1527557== Source and destination overlap in memcpy(0x1000104, 0x1000104, 4) > > ==00:00:00:28.322 1527557== at 0x4C2E74D: memcpy@@GLIBC_2.14 (vg_replace_strmem.c:1035) > > ==00:00:00:28.322 1527557== by 0xA9A57B: qunique (qunique.h:34) > > ==00:00:00:28.322 1527557== by 0xA9A843: InitCatalogCache (syscache.c:1056) > > ==00:00:00:28.322 1527557== by 0xAB6B18: InitPostgres (postinit.c:682) > > ==00:00:00:28.322 1527557== by 0x91F98E: PostgresMain (postgres.c:3909) > > ==00:00:00:28.322 1527557== by 0x872DE9: BackendRun (postmaster.c:4498) > > ==00:00:00:28.322 1527557== by 0x8725B3: BackendStartup (postmaster.c:4189) > > ==00:00:00:28.322 1527557== by 0x86E7F4: ServerLoop (postmaster.c:1727) > > ==00:00:00:28.322 1527557== by 0x86E0AA: PostmasterMain (postmaster.c:1400) > > ==00:00:00:28.322 1527557== by 0x77CB56: main (main.c:210) > > ==00:00:00:28.322 1527557== > > { > > > > Memcheck:Overlap > > fun:memcpy@@GLIBC_2.14 > > fun:qunique > > fun:InitCatalogCache > > fun:InitPostgres > > fun:PostgresMain > > fun:BackendRun > > fun:BackendStartup > > fun:ServerLoop > > fun:PostmasterMain > > fun:main > > } > > > > This is like the problem fixed in 9a9473f; the precedent from there would be > > to test src!=dst before calling mempcy(), e.g. as attached. I suppose the > > alternative would be to add a suppression like the one 9a9473f removed. > > Thanks for fixing that. Glad to help. > > I do wonder why the Valgrind buildfarm animals haven't noticed. > > Optimisation levels? For example, I see that skink is using -Og, at > which level my local GCC inlines qunique() and memcpy() so that in the > case you quoted there's a MOV instruction and valgrind has nothing to > complain about. That explains it. I would have been using -O0. (It would be a nice bonus to have both an -O0 Valgrind buildfarm animal and an optimized Valgrind animal, since neither catches everything.)