NetBSD Problem Report #59240

From www@netbsd.org  Mon Mar 31 02:49:21 2025
Return-Path: <www@netbsd.org>
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 25DD41A9239
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 31 Mar 2025 02:49:21 +0000 (UTC)
Message-Id: <20250331024920.1398F1A923E@mollari.NetBSD.org>
Date: Mon, 31 Mar 2025 02:49:20 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: POSIX.1-2024: cancellation point audit
X-Send-Pr-Version: www-1.0

>Number:         59240
>Category:       lib
>Synopsis:       POSIX.1-2024: cancellation point audit
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          needs-pullups
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Mar 31 02:50:00 +0000 2025
>Closed-Date:    
>Last-Modified:  Fri Apr 25 13:10:00 +0000 2025
>Originator:     Taylor R Campbell
>Release:        current, 10, 9, ...
>Organization:
The NetPthread.2024-1 Cancellation
>Environment:
>Description:
We are missing various cancellation points and automatic tests for them:

https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/V2_chap02.html#tag_16_09_05_02
>How-To-Repeat:
code inspection
cancellation
>Fix:
Yes, please!

Mandatory cancellation points:

[x] accept()
[x] accept4()
[x] aio_suspend()
[x] clock_nanosleep()
[x] close()
[x] cnd_timedwait()
[x] cnd_wait()
[x] connect()
[x] creat()
[x] fcntl() with F_SETLKW or F_OFD_SETLKW
[ ] fcntl() with F_OFD_SETLKW [missing, PR kern/59241]
[x] fdatasync()
[x] fsync()
[x] lockf() with F_LOCK
[x] mq_receive()
[x] mq_send()
[x] mq_timedreceive()
[x] mq_timedsend()
[x] msgrcv()
[x] msgsnd()
[x] msync()
[x] nanosleep()
[x] open()
[x] openat()
[x] pause()
[x] poll()
[ ] posix_close() [missing, PR kern/58929]
[x] ppoll()
[x] pread()
[x] pselect()
[x] pthread_cond_clockwait()
[x] pthread_cond_timedwait()
[x] pthread_cond_wait()
[x] pthread_join()
[x] pthread_testcancel()
[x] pwrite()
[x] read()
[x] readv()
[x] recv()
[x] recvfrom()
[x] recvmsg()
[x] select()
[x] send()
[x] sendmsg()
[x] sendto()
[x] sigsuspend()
[x] sigtimedwait()
[x] sigwait()
[x] sigwaitinfo()
[x] sleep()
[x] tcdrain()
[x] thrd_join()
[x] thrd_sleep()
[x] wait()
[x] waitid()
[x] waitpid()
[x] write()
[x] writev()

>Release-Note:

>Audit-Trail:
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59240 CVS commit: src
Date: Mon, 31 Mar 2025 13:57:07 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Mon Mar 31 13:57:06 UTC 2025

 Modified Files:
 	src/distrib/sets/lists/debug: mi
 	src/distrib/sets/lists/tests: mi
 	src/tests/lib/libpthread: Makefile
 Added Files:
 	src/tests/lib/libpthread: t_cancellation.c

 Log Message:
 pthread_cancel(3): Add some automatic tests.

 PR lib/59240: POSIX.1-2024: cancellation point audit
 PR lib/59134: POSIX-1.2024: pthread_setcancelstate must be
 async-signal-safe


 To generate a diff of this commit:
 cvs rdiff -u -r1.470 -r1.471 src/distrib/sets/lists/debug/mi
 cvs rdiff -u -r1.1362 -r1.1363 src/distrib/sets/lists/tests/mi
 cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libpthread/Makefile
 cvs rdiff -u -r0 -r1.1 src/tests/lib/libpthread/t_cancellation.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59240 CVS commit: src
Date: Mon, 31 Mar 2025 14:23:11 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Mon Mar 31 14:23:11 UTC 2025

 Modified Files:
 	src/distrib/sets/lists/base: shl.mi
 	src/distrib/sets/lists/debug: shl.mi
 	src/lib/libpthread: pthread_cancelstub.c pthread_mi.expsym
 	    shlib_version
 	src/tests/lib/libpthread: t_cancellation.c

 Log Message:
 libpthread(3): Add missing cancellation points.

 - accept4
 - tcdrain

 XXX Should our nonstandard alias paccept(2) also be a cancellation
 point?

 PR lib/59240: POSIX.1-2024: cancellation point audit


 To generate a diff of this commit:
 cvs rdiff -u -r1.998 -r1.999 src/distrib/sets/lists/base/shl.mi
 cvs rdiff -u -r1.358 -r1.359 src/distrib/sets/lists/debug/shl.mi
 cvs rdiff -u -r1.46 -r1.47 src/lib/libpthread/pthread_cancelstub.c
 cvs rdiff -u -r1.1 -r1.2 src/lib/libpthread/pthread_mi.expsym
 cvs rdiff -u -r1.19 -r1.20 src/lib/libpthread/shlib_version
 cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libpthread/t_cancellation.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->needs-pullups
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Tue, 01 Apr 2025 01:40:16 +0000
State-Changed-Why:
fixed in HEAD (except for posix_close and fcntl F_OFD_SETLKW which we
currently lack), needs pullup-10 and pullup-9


From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59240 CVS commit: src/lib/libpthread
Date: Wed, 2 Apr 2025 17:18:44 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Wed Apr  2 17:18:44 UTC 2025

 Modified Files:
 	src/lib/libpthread: pthread_cancelstub.c

 Log Message:
 libpthread: Fix signature of _sys_paccept symbol for paccept(2).

 This is not, in fact, an alias for accept4(2): it has an extra
 argument for a signal mask to restore while sleeping.

 It would be nice if we had a .h file which could check the signature
 in both definition and use, but that might be tricky to arrange.

 PR lib/59240: POSIX.1-2024: cancellation point audit


 To generate a diff of this commit:
 cvs rdiff -u -r1.47 -r1.48 src/lib/libpthread/pthread_cancelstub.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59240 CVS commit: src/sys/compat/sys
Date: Fri, 4 Apr 2025 20:51:32 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Fri Apr  4 20:51:32 UTC 2025

 Modified Files:
 	src/sys/compat/sys: event.h

 Log Message:
 compat/sys/event.h: Add struct timespec50 forward declaration.

 Needed below by function prototypes.

 PR lib/59240: POSIX.1-2024: cancellation point audit


 To generate a diff of this commit:
 cvs rdiff -u -r1.4 -r1.5 src/sys/compat/sys/event.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59240 CVS commit: src/lib/libpthread
Date: Fri, 4 Apr 2025 20:52:30 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Fri Apr  4 20:52:30 UTC 2025

 Modified Files:
 	src/lib/libpthread: pthread_cancelstub.c

 Log Message:
 libpthread: Sort cancelstub definitions.

 No functional change intended.

 PR lib/59240: POSIX.1-2024: cancellation point audit


 To generate a diff of this commit:
 cvs rdiff -u -r1.49 -r1.50 src/lib/libpthread/pthread_cancelstub.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59240 CVS commit: src/lib/libpthread
Date: Fri, 4 Apr 2025 20:53:38 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Fri Apr  4 20:53:38 UTC 2025

 Modified Files:
 	src/lib/libpthread: pthread_cancelstub.c

 Log Message:
 pthread_cancelstub.c: Use restrict, not __restrict.

 Only reason to use __restrict is to make header files safe for
 pre-C99 clients, but we have built this code as C99 for many years
 (and we build it as C11 now anyway).

 No functional change intended.

 PR lib/59240: POSIX.1-2024: cancellation point audit


 To generate a diff of this commit:
 cvs rdiff -u -r1.50 -r1.51 src/lib/libpthread/pthread_cancelstub.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59240 CVS commit: src/tests/lib/libpthread
Date: Sat, 5 Apr 2025 11:22:33 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Sat Apr  5 11:22:32 UTC 2025

 Modified Files:
 	src/tests/lib/libpthread: Makefile t_cancellation.c
 Added Files:
 	src/tests/lib/libpthread: cancelpoint.h t_compat_cancel.c

 Log Message:
 Add tests for compat functions as cancellation points.

 While here, test kevent too.

 PR lib/59240: POSIX.1-2024: cancellation point audit
 PR lib/59247: pthread_cancelstub.c is inadequately tested


 To generate a diff of this commit:
 cvs rdiff -u -r1.17 -r1.18 src/tests/lib/libpthread/Makefile
 cvs rdiff -u -r0 -r1.1 src/tests/lib/libpthread/cancelpoint.h \
     src/tests/lib/libpthread/t_compat_cancel.c
 cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libpthread/t_cancellation.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59240 CVS commit: src/distrib/sets/lists
Date: Sat, 5 Apr 2025 13:13:34 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Sat Apr  5 13:13:34 UTC 2025

 Modified Files:
 	src/distrib/sets/lists/debug: mi
 	src/distrib/sets/lists/tests: mi

 Log Message:
 t_compat_cancel: Update set lists.

 PR lib/59240: POSIX.1-2024: cancellation point audit
 PR lib/59247: pthread_cancelstub.c is inadequately tested


 To generate a diff of this commit:
 cvs rdiff -u -r1.472 -r1.473 src/distrib/sets/lists/debug/mi
 cvs rdiff -u -r1.1364 -r1.1365 src/distrib/sets/lists/tests/mi

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59240 CVS commit: src/lib/libc/compat/arch/ia64/sys
Date: Mon, 7 Apr 2025 20:21:11 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Mon Apr  7 20:21:11 UTC 2025

 Modified Files:
 	src/lib/libc/compat/arch/ia64/sys: Makefile.inc
 Added Files:
 	src/lib/libc/compat/arch/ia64/sys: compat_sigprocmask.S
 	    compat_sigsuspend.S

 Log Message:
 ia64: Include compat13 sigprocmask and sigsuspend stubs.

 All the other ports already do this.  Although ia64 was imported long
 after 1.4, the same is true of other ports that nevertheless include
 these stubs, like amd64.

 We could invent a new __NetBSD_Compat_Min__ macro like
 __NetBSD_Version__ that tells the earliest version of NetBSD for
 which we aim to support compat binaries, and use that to
 conditionalize tests like t_compat_cancel.c.  But that's a bit more
 trouble for something we can dispense with by a couple tiny syscall
 stubs.

 Should fix build for:

 PR lib/59240: POSIX.1-2024: cancellation point audit
 PR lib/59247: pthread_cancelstub.c is inadequately tested


 To generate a diff of this commit:
 cvs rdiff -u -r1.3 -r1.4 src/lib/libc/compat/arch/ia64/sys/Makefile.inc
 cvs rdiff -u -r0 -r1.1 src/lib/libc/compat/arch/ia64/sys/compat_sigprocmask.S \
     src/lib/libc/compat/arch/ia64/sys/compat_sigsuspend.S

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59240 CVS commit: src/tests/lib/libpthread
Date: Tue, 8 Apr 2025 13:30:45 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Tue Apr  8 13:30:45 UTC 2025

 Modified Files:
 	src/tests/lib/libpthread: Makefile

 Log Message:
 tests/lib/libpthread/t_compat_cancel: Make linker warnings non-fatal.

 We will get warnings like:

 /home/riastradh/netbsd/current/src/tests/lib/libpthread/t_compat_cancel.c:233: warning: warning: reference to compatibility sigsuspend(); include <signal.h> for correct reference

 This is intended -- t_compat_cancel deliberately uses the compat
 symbols, not the modern symbols, in order to test the compat symbols.

 Fixes clang build because bsd.sys.mk enables -Wl,--fatal-warnings in
 LDFLAGS by default.

 PR lib/59240: POSIX.1-2024: cancellation point audit
 PR lib/59247: pthread_cancelstub.c is inadequately tested


 To generate a diff of this commit:
 cvs rdiff -u -r1.18 -r1.19 src/tests/lib/libpthread/Makefile

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59240 CVS commit: src/tests/lib/libpthread
Date: Fri, 11 Apr 2025 02:07:17 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Fri Apr 11 02:07:17 UTC 2025

 Modified Files:
 	src/tests/lib/libpthread: t_compat_cancel.c

 Log Message:
 t_compat_cancel: Fix compat numbers to match reality.

 - msync is as it existed in 1.2, and is implemented by compat12;
   __msync13 was new in 1.3.

 - sigsuspend is as it existed in 1.3, and is implemented by compat13;
   __sigsuspend14 was new in 1.4.

 (But, while select is as it existed in 5.0, and is implemented by
 compat50, __select50 was new in _6.0_, not in 5.0.)

 No functional change intended other than to rename the test cases for
 clarity.

 PR lib/59240: POSIX.1-2024: cancellation point audit
 PR lib/59247: pthread_cancelstub.c is inadequately tested


 To generate a diff of this commit:
 cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libpthread/t_compat_cancel.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59240 CVS commit: src/tests/lib/libpthread
Date: Fri, 25 Apr 2025 13:09:44 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Fri Apr 25 13:09:44 UTC 2025

 Modified Files:
 	src/tests/lib/libpthread: t_compat_cancel.c

 Log Message:
 t_compat_cancel: Use -1 rather than SIGALRM for expected signal.

 On kernels without (e.g.) COMPAT_13, we get SIGSYS rather than
 SIGALRM if the cancellation point doesn't cancel the syscall.

 Won't help if we try to interrupt in-progress waits, but currently
 none of the tests do that; we'll burn that bridge when we come to it,

 PR lib/59240: POSIX.1-2024: cancellation point audit
 PR lib/59247: pthread_cancelstub.c is inadequately tested


 To generate a diff of this commit:
 cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libpthread/t_compat_cancel.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2025 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.