Re: [PATCH v2] Fix races in Windows pthread emulation

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: harrisontbooth(at)gmail(dot)com, Alexander Lakhin <exclusion(at)gmail(dot)com>, Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH v2] Fix races in Windows pthread emulation
Date: 2026-10-13 08:03:21
Message-ID: 0f62028a-54bf-427b-9bed-65ee89b34b7c@iki.fi
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 13/10/2026 02:37, harrisontbooth(at)gmail(dot)com wrote:
> Heikki, do the acquire loads and separate pthread_once work address
> your concerns?

Yeah.

> + /* Acquire the initialization state without a read-modify-write. */
> +#ifdef _MSC_VER
> + if (ReadAcquire(&mp->initstate) != 1)
> +#else
> + if (__atomic_load_n(&mp->initstate, __ATOMIC_ACQUIRE) != 1)
> +#endif

Hmm, so ReadAcquire is only available on Visual Studio, and the
else-branch is for mingw builds? Is there no atomic read intrinsic
similar InterlockedCompareExchange() that would work on both?

- Heikki

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nisha Moond 2026-10-13 08:05:21 Re: Proposal: Conflict log history table for Logical Replication
Previous Message Daniel Gustafsson 2026-10-13 07:59:26 Re: [PATCH v1] Fix tab completion for concurrent materialized view refresh