Skip to contentSkip to conversation

OpenPOSIX: Allow 0 return value when detaching or joining joined thread

PATCH Applied Wei Gao via ltp 3 participants 8 messages May 9 – May 12

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 OpenPOSIX: Allow 0 return value when detaching or joining joined thread

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.

---
 .../conformance/interfaces/pthread_detach/4-2.c             | 6 +++---
 .../conformance/interfaces/pthread_join/6-2.c               | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/4-2.c +3 -3
index a6dc83efd..1e7b84117 100644
@@ -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;
 
testcases/open_posix_testsuite/conformance/interfaces/pthread_join/6-2.c +3 -3
index bd7e295d6..4052a55e2 100644
@@ -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;
 	}
Signature · 5 lines
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Wei,

Quoted 4 lines · Wei Gao

OpenPOSIX: Allow 0 return value when detaching or joining joined thread

These are caused by glibc commit 5da15b15adab661c80e373b6af89be0b5fa5b3ad ("nptl: Do not use pthread set_tid_address as state synchronization (BZ #19951)").

The motivation is clear and the fix looks correct — accepting 0 in addition to ESRCH matches the new glibc behavior.

Quoted 2 lines

The new glibc logic removed the explicit validation of thread handles that previously returned ESRCH:

The commit message is missing a Signed-off-by: tag. Please add:

---
Note:

Our agent completed the review of the patch. The full review can be found at: https://github.com/linux-test-project/ltp-agent/actions/runs/25721673051

The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Hi Wei,

if it's ok for you, I can merge it with Signed-off tag.

Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw
Quoted 3 lines · Andrea Cervesato

Hi Wei,

if it's ok for you, I can merge it with Signed-off tag.

My patch has Signed-off, i have no idea why AI can't find it :)

Quoted 6 lines

Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

Hi Wei,

Quoted 11 lines · Andrea Cervesato
Quoted 3 lines

Hi Wei,

if it's ok for you, I can merge it with Signed-off tag.

My patch has Signed-off, i have no idea why AI can't find it :)

Quoted 6 lines

Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

--- 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;
-

Everything that is after --- is threated as a patch comment by the git am command, as well as b4. So after applying the patch, agent correct seen SOB tag missing nad reported it in the review.

I will remove this comment in the patch before merge.

Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#7 lore raw
In reply to Wei Gao via ltp

Hi!

Quoted 41 lines

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

(quoted diff) +0 -6
-  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.

---
 .../conformance/interfaces/pthread_detach/4-2.c             | 6 +++---
 .../conformance/interfaces/pthread_join/6-2.c               | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/4-2.c +1 -1
index a6dc83efd..1e7b84117 100644
@@ -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
  *
  */
 

testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/4-2.c int test_main(int argc PTS_ATTRIBUTE_UNUSED, char **argv PTS_ATTRIBUTE_UNUSED) · line 66

Quoted 10 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/4-2.c +2 -2
@@ -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:

testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/4-2.c +6 -1
index 1e7b84117..fc7a6e9c9 100644
@@ -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);
Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp