NetBSD Problem Report #59723

From rhialto@falu.nl  Sat Oct 25 15:20:07 2025
Return-Path: <rhialto@falu.nl>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits)
	 client-signature RSA-PSS (2048 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id F0B411A923A
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 25 Oct 2025 15:20:06 +0000 (UTC)
Message-Id: <202510251512.59PFCisN029405@murthe.falu.nl>
Date: Sat, 25 Oct 2025 17:12:44 +0200 (CEST)
From: rhialto@falu.nl
Reply-To: rhialto@falu.nl
To: gnats-bugs@NetBSD.org
Subject: Our pthread_setname_np() requires 3 args, everybody else has 2
X-Send-Pr-Version: 3.95

>Number:         59723
>Category:       lib
>Synopsis:       Our pthread_setname_np() requires 3 args, everybody else has 2
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 25 15:25:00 +0000 2025
>Last-Modified:  Sat Oct 25 21:35:00 +0000 2025
>Originator:     Rhialto
>Release:        NetBSD 10.1
>Organization:

>Environment:
System: NetBSD murthe.falu.nl 10.1 NetBSD 10.1 (GENERIC) #0: Mon Dec 16 13:08:11 UTC 2024 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
	I ran into a program that does this:

	#ifdef _GNU_SOURCE
	    pthread_setname_np(pthread_self(), "USBSID Thread");
	#endif

	while also using devel/SDL. `sdl-config --cflags` includes
	-D_GNU_SOURCE=1.

	This errored out with

	  CXX      USBSID.o
	../../../../vice/src/lib/libusbsiddrv/USBSID.cpp: In member function 'void* USBSID_NS::USBSID_Class::USBSID_Thread()':
	../../../../vice/src/lib/libusbsiddrv/USBSID.cpp:623:21: error: too few arguments to function 'int pthread_setname_np(pthread_t, const char*, void*)'
	  623 |   pthread_setname_np(pthread_self(), "USBSID Thread");
	      |   ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	compilation terminated due to -Wfatal-errors.

	Other OSes seem to use only 2 arguments for pthread_setname_np():

	FreeBSD: https://man.freebsd.org/cgi/man.cgi?query=pthread_setname_np&apropos=0&sektion=0&manpath=FreeBSD+14.3-RELEASE+and+Ports&arch=default&format=html

	Linux: https://manpages.debian.org/bullseye/manpages-dev/pthread_setname_np.3.en.html

	OpenBSD doesn't seem to have the function (or at least no manpage on
https://man.openbsd.org/)

	On irc #netbsd, this was found:

	changeset:   512354:f7dffed1422c
	branch:      trunk
	user:        thorpej <thorpej@NetBSD.org>
	date:        Wed Feb 26 22:02:48 2003 +0000
	summary:     Add support for naming a thread, using an API 
	compatible with Tru64 Unix:

	https://archive.org/details/CompaqTru64UNIX51GuidetothePOSIXThreadsLibraryARH9RBTE2000/page/n389/mode/2up

	In src-public this is changeset:   136073:f7dffed1422c.

	(It looks like Tru64 and NetBSD were first, but the precedent was
	ignored by the other OSes...)

>How-To-Repeat:
	Build a the code as quoted above, or get the current svn version of
	the VICE emulator and compile it with the SDL GUI.
>Fix:
	A suggestion was to make it
	pthread_setname_np(t, formatstring, ...<varargs>...)
	instead.

	That ought to be compatible with our usage and also with the other's.

-Olaf.
-- 
___ Olaf 'Rhialto' Seibert                            <rhialto/at/falu.nl>
\X/ There is no AI. There is just someone else's work.           --I. Rose

>Audit-Trail:
From: Thomas Klausner <wiz@gatalith.at>
To: NetBSD bugtracking <gnats-bugs@netbsd.org>
Cc: 
Subject: Re: lib/59723: Our pthread_setname_np() requires 3 args, everybody
 else has 2
Date: Sat, 25 Oct 2025 23:30:44 +0200

 On Sat, Oct 25, 2025 at 03:25:00PM +0100, rhialto@falu.nl wrote:
 > 	(It looks like Tru64 and NetBSD were first, but the precedent was
 > 	ignored by the other OSes...)

 Just for the record, we've already fixed quite some software for that
 (and would need to fix it back if we changed signatures).
  Thomas

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.