Thread View: muc.lists.freebsd.bugs
3 messages
3 total messages
Started by bugzilla-noreply
Fri, 13 Nov 2026 22:53
[Bug 300754] linux: prctl(PR_SET_NAME) renames the whole process instead of the calling thread
Author: bugzilla-noreply
Date: Fri, 13 Nov 2026 22:53
Date: Fri, 13 Nov 2026 22:53
98 lines
5272 bytes
5272 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300754
Bug ID: 300754
Summary: linux: prctl(PR_SET_NAME) renames the whole process
instead of the calling thread
Product: Base System
Version: 16.0-CURRENT
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: kern
Assignee: bugs@FreeBSD.org
Reporter: rbranco@suse.com
Attachment #277279 text/plain
mime type:
Created attachment 277279
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=277279&action=edit
prctl_name.c
On Linux, prctl(PR_SET_NAME) and prctl(PR_GET_NAME) operate on the name
of the calling thread. The main thread's name is also the process name
shown in /proc/<pid>/stat, /proc/<pid>/comm and ps(1).
The Linuxulator implements both operations on p_comm instead
(linux_prctl() in sys/compat/linux/linux_misc.c):
- PR_SET_NAME from any thread renames the whole process, and the
thread's own td_name is never changed.
whichever thread called PR_SET_NAME most recently, not the caller's
own name.
glibc's pthread_setname_np() and pthread_getname_np() use these prctl()
operations when a thread names itself. So any multithreaded Linux
program that names its worker threads ends up showing the name of
whichever thread was named last in ps(1) and top(1), and
pthread_getname_np(pthread_self()) returns the wrong name. Thread names
set this way are also not visible in "ps -H" or "top -H", because
td_name is never updated.
How to reproduce:
Build the attached prctl_name.c on Linux:
cc -static -pthread -o prctl_name prctl_name.c
The main thread names itself "main". It starts a thread, which names
itself "worker", and joins it. Then it checks its own name with
PR_GET_NAME, with pthread_getname_np() and through /proc/self/stat.
Native Linux:
worker: PR_GET_NAME after renaming itself got worker want worker
ok
main: PR_GET_NAME after worker renamed got main want main
ok
main: pthread_getname_np() got main want main
ok
process name in /proc/self/stat got main want main
ok
FreeBSD <version> with linux64.ko and linprocfs:
worker: PR_GET_NAME after renaming itself got worker want worker
ok
main: PR_GET_NAME after worker renamed got worker want main
FAIL
main: pthread_getname_np() got worker want main
FAIL
process name in /proc/self/stat got worker want main
FAIL
Expected: as on Linux, PR_SET_NAME renames only the calling thread, and
the process name changes only when the main thread renames itself.
Proposed fix: set and get td->td_name in PR_SET_NAME/PR_GET_NAME, and
also update p_comm when the caller is the main thread (em_tid == p_pid).
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
[Bug 300754] linux: prctl(PR_SET_NAME) renames the whole process instead of the calling thread
Author: bugzilla-noreply
Date: Fri, 13 Nov 2026 22:53
Date: Fri, 13 Nov 2026 22:53
13 lines
2440 bytes
2440 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300754 --- Comment #1 from Ricardo Branco <rbranco@suse.com> --- Fix: https://github.com/freebsd/freebsd-src/pull/2550 -- You are receiving this mail because: You are the assignee for the bug. -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
[Bug 300754] linux: prctl(PR_SET_NAME) renames the whole process instead of the calling thread
Author: bugzilla-noreply
Date: Sat, 14 Nov 2026 08:45
Date: Sat, 14 Nov 2026 08:45
16 lines
2559 bytes
2559 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300754
Mark Linimon <linimon@FreeBSD.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|bugs@FreeBSD.org |emulation@FreeBSD.org
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads