[LTP] [PATCH v1] OpenPOSIX: Allow 0 return value when detaching or joining joined thread

Wei Gao wegao@suse.com
Sat May 9 10:26:47 CEST 2026


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;
 
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_join/6-2.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_join/6-2.c
index bd7e295d6..4052a55e2 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_join/6-2.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_join/6-2.c
@@ -61,11 +61,11 @@ int test_main(int argc PTS_ATTRIBUTE_UNUSED, char **argv PTS_ATTRIBUTE_UNUSED)
 
 	/*
 	 * Now that the thread has returned, try to join it again.
-	 * It should give the error code of ESRCH.
+	 * It should give the error code of ESRCH or 0.
 	 */
 	ret = pthread_join(new_th, NULL);
-	if (ret != ESRCH) {
-		printf("Test FAILED: Return code should be ESRCH, but is: "
+	if (ret != ESRCH && ret != 0) {
+		printf("Test FAILED: Return code should be ESRCH or 0, but is: "
 		       "%d instead.\n", ret);
 		return PTS_FAIL;
 	}
-- 
2.52.0



More information about the ltp mailing list