Re: `pg_ctl init` crashes when run concurrently; semget(2) suspected

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Gavin Panella <gavinpanella(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: `pg_ctl init` crashes when run concurrently; semget(2) suspected
Date: 2025-08-13 00:45:19
Message-ID: CA+hUKGKAPR=NXxMTCmEomCUpq+mrPLDVyfVa4bKZqfDjwyzD7Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Aug 13, 2025 at 11:29 AM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> FWIW in early prototype multithreading patches you can just use
> sem_init() on all these systems since you don't need pshared=1.

Oops, I misremembered that. It works on NetBSD and OpenBSD, but not
macOS :-(.

Hmm, but it looks like there has been a new development in macOS 15.
They have finally made the futex API public:

https://developer.apple.com/documentation/os/os_sync_wait_on_address

That was one of the sticking points for my patch that added our own
replacement sem_init() implementation. At the time the only "proper"
way to reach the undocumented and undeclared
__ulock_wait()/__ulock_wake() functions was to write a module in C++
using std::atomic<int>::wait()/notify(), which I had started to wonder
about, but here it is with a shiny new C interface and documentation.

Maybe I should have another go at that!

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Japin Li 2025-08-13 00:56:12 Standardize LSN-based filename
Previous Message Michael Paquier 2025-08-12 23:36:51 Re: CI failures with Windows - VS2019 jobs