[Bug 150959] [libc] Stub pthread_once in libc should call _libc_once

[email protected] Mon, 13 Apr 2026 18:05:45 +0000
Newsgroups gmane.os.freebsd.devel.threading
Message-ID <[email protected]/bugzilla/>
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D150959

--- Comment #7 from Ed Maste <[email protected]> ---
The bug of pthread_once returning 0 but not calling the function is indeed
fixed -- pthread_once now returns an error and does not call the function.


#include <stdbool.h>
#include <stdio.h>
#include <pthread.h>

static pthread_once_t once =3D PTHREAD_ONCE_INIT;
static bool called;

static void
init(void)
{
        called =3D true;
}

int main(void)
{
        int ret =3D pthread_once(&once, init);
        printf("pthread_once returned %d, init was %scalled\n", ret,
            called ? "" : "not ");
}

$ cc repro.c && ./a.out
pthread_once returned 78, init was not called

It would be nice if we can still improve things as @jhb suggests

--=20
You are receiving this mail because:
You are the assignee for the bug.=