[LTP] [PATCH] open_posix: remove pthread_kill/6-1

Jan Stancek jstancek@redhat.com
Wed Oct 6 15:31:14 CEST 2021


Test fails on recent glibc (glibc-2.34).

Per https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09_02:
  If an application attempts to use a thread ID whose lifetime has ended,
  the behavior is undefined."

In some scenarios leading to crash. Example from Florian Weimer [1]:
  Invoking pthread_kill with a thread ID whose lifetime has ended is
  undefined behavior, so this test is invalid. For example, if you run
  this test with GLIBC_TUNABLES=glibc.pthread.stack_cache_size=0,
  the pthread_kill call crashes because without a stack cache,
  the underlying thread control block is unmapped as part of pthread_join."

[1] https://gitlab.com/cki-project/kernel-tests/-/issues/768

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 .../conformance/interfaces/pthread_kill/6-1.c | 62 -------------------
 .../interfaces/pthread_kill/assertions.xml    |  4 --
 .../interfaces/pthread_kill/coverage.txt      |  1 -
 3 files changed, 67 deletions(-)
 delete mode 100644 testcases/open_posix_testsuite/conformance/interfaces/pthread_kill/6-1.c

diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_kill/6-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_kill/6-1.c
deleted file mode 100644
index a462ba8e04ce..000000000000
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_kill/6-1.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2002-3, Intel Corporation. All rights reserved.
- * Created by:  salwan.searty REMOVE-THIS AT intel DOT com
- * This file is licensed under the GPL license.  For the full content
- * of this license, see the COPYING file at the top level of this
- * source tree.
- *
- * Test that the pthread_kill() function shall return ESRCH when no
- * thread could be found corresponding to that specified by the given
- * thread ID.
- *
- * NOTE: Cannot find 6-1.c in PTS cvs. So write this one.
- */
-
-#include <pthread.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include "posixtest.h"
-
-static void *thread_function(void *arg PTS_ATTRIBUTE_UNUSED)
-{
-	/* Does nothing */
-	pthread_exit(NULL);
-
-	/* To please some compilers */
-	return NULL;
-}
-
-int main(void)
-{
-	pthread_t child_thread;
-	pthread_t invalid_tid;
-
-	int rc;
-
-	rc = pthread_create(&child_thread, NULL, thread_function, NULL);
-	if (rc != 0) {
-		printf("Error at pthread_create()\n");
-		return PTS_UNRESOLVED;
-	}
-
-	rc = pthread_join(child_thread, NULL);
-	if (rc != 0) {
-		printf("Error at pthread_join()\n");
-		return PTS_UNRESOLVED;
-	}
-
-	/* Now the child_thread exited, it is an invalid tid */
-	memcpy(&invalid_tid, &child_thread, sizeof(pthread_t));
-
-	if (pthread_kill(invalid_tid, 0) == ESRCH) {
-		printf("pthread_kill() returns ESRCH.\n");
-		return PTS_PASS;
-	}
-
-	printf("Test Fail\n");
-	return PTS_FAIL;
-}
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_kill/assertions.xml b/testcases/open_posix_testsuite/conformance/interfaces/pthread_kill/assertions.xml
index 2289b9bfbb2e..fa74c312bebb 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_kill/assertions.xml
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_kill/assertions.xml
@@ -16,10 +16,6 @@
   <assertion id="5" tag="ref:XSH6:33594:33595 pt:THR">
     No signal shall be sent if the pthread_kill() function fails.
   </assertion>
-  <assertion id="6" tag="ref:XSH6:33598:33599 pt:THR">
-    [ESRCH] No thread could be found corresponding to that specified by
-    the given thread ID.
-  </assertion>
   <assertion id="7" tag="ref:XSH6:33600:33600 pt:THR">
     [EINVAL] The value of the sig argument is an invalid or unsupported
     signal number.
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_kill/coverage.txt b/testcases/open_posix_testsuite/conformance/interfaces/pthread_kill/coverage.txt
index 03dc3d5a718a..8cfa3d8b6ba3 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_kill/coverage.txt
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_kill/coverage.txt
@@ -6,6 +6,5 @@ Assertion	Status
 3		YES
 4		IMPLICITLY tested by assertions 6 and 7.
 5		IMPLICITLY tested by assertions 6 and 7.
-6		YES
 7		YES
 8		WON'T test. No way to interrupt the pthread_kill() call.
-- 
2.27.0



More information about the ltp mailing list