[LTP] [PATCH v1] OpenPOSIX: Allow 0 return value when detaching or joining joined thread
Cyril Hrubis
chrubis@suse.cz
Tue May 12 13:10:56 CEST 2026
Hi!
> Latest test in our openqa setup (Linux 7.1-rc2, Glibc 2.43) show following errors:
> - pthread_detach_4-2: Test FAILED: Incorrect return code: 0 instead of ESRCH
> - pthread_join_6-2: Test FAILED: Return code should be ESRCH, but is: 0 instead.
>
> These are caused by glibc commit 5da15b15adab661c80e373b6af89be0b5fa5b3ad
> ("nptl: Do not use pthread set_tid_address as state synchronization (BZ #19951)").
>
> The new glibc logic removed the explicit validation of thread handles that
> previously returned ESRCH:
>
> --- a/nptl/pthread_detach.c
> - if (INVALID_NOT_TERMINATED_TD_P (pd))
> - return ESRCH;
>
> --- a/nptl/pthread_join_common.c
> - if (INVALID_NOT_TERMINATED_TD_P (pd))
> - return ESRCH;
> -
>
> Update the tests to allow both return codes.
>
> Signed-off-by: Wei Gao <wegao@suse.com>
> ---
> .../conformance/interfaces/pthread_detach/4-2.c | 6 +++---
> .../conformance/interfaces/pthread_join/6-2.c | 6 +++---
> 2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/4-2.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/4-2.c
> index a6dc83efd..1e7b84117 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/4-2.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/4-2.c
> @@ -18,7 +18,7 @@
> * 1. Create a thread.
> * 2.Wait 'till the thread exits.
> * 3.Try and detach this thread.
> - * 4.Check the return value and make sure it is ESRCH
> + * 4.Check the return value and make sure it is ESRCH or 0
> *
> */
>
> @@ -59,9 +59,9 @@ int test_main(int argc PTS_ATTRIBUTE_UNUSED, char **argv PTS_ATTRIBUTE_UNUSED)
> ret = pthread_detach(new_th);
>
> /* Check return value of pthread_detach() */
> - if (ret != ESRCH) {
> + if (ret != ESRCH && ret != 0) {
> printf
> - ("Test FAILED: Incorrect return code: %d instead of ESRCH\n",
> + ("Test FAILED: Incorrect return code: %d instead of ESRCH or 0\n",
> ret);
> return PTS_FAIL;
Technically since this is open posix testsuite we should PTS_UNTESTED on
0 since we were not able to trigger the error since the implementation
does not implement the optional behavior.
Something as:
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/4-2.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/4-2.c
index 1e7b84117..fc7a6e9c9 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/4-2.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/4-2.c
@@ -58,8 +58,13 @@ int test_main(int argc PTS_ATTRIBUTE_UNUSED, char **argv PTS_ATTRIBUTE_UNUSED)
/* Detach the non-existant thread. */
ret = pthread_detach(new_th);
+ if (ret == 0) {
+ printf("Test UNTESTED: Implementation does not return ESCHR\n");
+ return PTS_UNTESTED;
+ }
+
/* Check return value of pthread_detach() */
- if (ret != ESRCH && ret != 0) {
+ if (ret != ESRCH) {
printf
("Test FAILED: Incorrect return code: %d instead of ESRCH or 0\n",
ret);
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list