Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eISrM-0005U0-GT for pgsql-committers@arkaria.postgresql.org; Sat, 25 Nov 2017 05:18:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eISrM-000086-36 for pgsql-committers@arkaria.postgresql.org; Sat, 25 Nov 2017 05:18:36 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eISrL-00007v-UO for pgsql-committers@lists.postgresql.org; Sat, 25 Nov 2017 05:18:35 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eISrI-0004cA-MJ for pgsql-committers@postgresql.org; Sat, 25 Nov 2017 05:18:35 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id vAP5IPZg006190; Sat, 25 Nov 2017 00:18:25 -0500 From: Tom Lane To: Tomas Vondra cc: Andres Freund , Simon Riggs , pgsql-committers Subject: Re: pgsql: Generational memory allocator In-reply-to: References: <20171123001649.y2nf7422iay6cw3v@alap3.anarazel.de> <16449.1511548313@sss.pgh.pa.us> <4618.1511573138@sss.pgh.pa.us> Comments: In-reply-to Tomas Vondra message dated "Sat, 25 Nov 2017 05:54:18 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <6188.1511587105.1@sss.pgh.pa.us> Date: Sat, 25 Nov 2017 00:18:25 -0500 Message-ID: <6189.1511587105@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Tomas Vondra writes: > BTW I also see these failures in hstore: > ==15168== Source and destination overlap in memcpy(0x5d0fed0, 0x5d0fed0, 40) > ==15168== at 0x4C2E00C: memcpy@@GLIBC_2.14 (vg_replace_strmem.c:1018) > ==15168== by 0x15419A06: hstoreUniquePairs (hstore_io.c:343) > ==15168== by 0x15419EE4: hstore_in (hstore_io.c:416) Huh ... > Seems hstoreUniquePairs may call memcpy with the same pointers in some > cases (which looks a bit dubious). But the code is ancient, so it's > strange it didn't fail before. Quite. It's easy to see how to avoid the nominally-undefined behavior: - memcpy(res, ptr, sizeof(Pairs)); + if (res != ptr) + memcpy(res, ptr, sizeof(Pairs)); but this should surely have been noticed by valgrind tests before. The case doesn't necessarily occur --- if the first two items in sorted order are dups, it won't --- but if you're seeing it occur in regression testing then skink should have seen it as well. regards, tom lane