Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f4sF8-0007lZ-Dt for pgsql-hackers@arkaria.postgresql.org; Sat, 07 Apr 2018 18:07:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f4sF7-0001JY-CW for pgsql-hackers@arkaria.postgresql.org; Sat, 07 Apr 2018 18:07:13 +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.89) (envelope-from ) id 1f4sF7-0001JO-5P for pgsql-hackers@lists.postgresql.org; Sat, 07 Apr 2018 18:07:13 +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 1f4sF3-0004Ed-OD for pgsql-hackers@postgresql.org; Sat, 07 Apr 2018 18:07:12 +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 w37I75bE007224; Sat, 7 Apr 2018 14:07:05 -0400 From: Tom Lane To: Andres Freund cc: pgsql-hackers@postgresql.org, Daniel Gustafsson Subject: Re: Bring atomic flag fallback up to snuff In-reply-to: <20180406233854.uni2h3mbnveczl32@alap3.anarazel.de> References: <20180406233854.uni2h3mbnveczl32@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Fri, 06 Apr 2018 16:38:54 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <7222.1523124425.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 07 Apr 2018 14:07:05 -0400 Message-ID: <7223.1523124425@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > As Daniel pointed out in: > https://postgr.es/m/FB948276-7B32-4B77-83E6-D00167F8EEB4@yesql.se the > pg_atomic_flag fallback implementation is broken. That has gone > unnoticed because the fallback implementation wasn't testable until now: > ... > The attached fixes the bug and removes the edge-cases by storing a value > separate from the semaphore. I should have done that from the start. > This is an ABI break, but given the fallback didn't work at all, I don't > think that's a problem for backporting. > Fix attached. Comments? pademelon says it's wrong. 2018-04-07 13:39:34.982 EDT [1197:89] pg_regress/lock LOG: statement: SEL= ECT test_atomic_ops(); TRAP: UnalignedPointer("(((uintptr_t) ((uintptr_t)(ptr)) + ((sizeof(*ptr))= - 1)) & ~((uintptr_t) ((sizeof(*ptr)) - 1))) !=3D (uintptr_t)(ptr)", File= : "../../../src/include/port/atomics.h", Line: 177) regards, tom lane