From f5a8ce775c803fa406bda378eb174407d365d503 Mon Sep 17 00:00:00 2001 From: He Zhe Date: Mon, 19 Aug 2019 21:56:33 +0800 Subject: ltp: Fix tgkill03 failure Backport a patch to fix the followig failure. tgkill03.c:94: FAIL: Defunct tid should have failed with ESRCH: SUCCESS (From OE-Core rev: 92e873c63499850f1f9461d3babde13d44bc8f9c) Signed-off-by: He Zhe Signed-off-by: Richard Purdie --- ...kill03-wait-for-defunct-tid-to-get-detach.patch | 75 ++++++++++++++++++++++ meta/recipes-extended/ltp/ltp_20190517.bb | 1 + 2 files changed, 76 insertions(+) create mode 100644 meta/recipes-extended/ltp/ltp/0001-syscalls-tgkill03-wait-for-defunct-tid-to-get-detach.patch diff --git a/meta/recipes-extended/ltp/ltp/0001-syscalls-tgkill03-wait-for-defunct-tid-to-get-detach.patch b/meta/recipes-extended/ltp/ltp/0001-syscalls-tgkill03-wait-for-defunct-tid-to-get-detach.patch new file mode 100644 index 0000000000..6ea26150fb --- /dev/null +++ b/meta/recipes-extended/ltp/ltp/0001-syscalls-tgkill03-wait-for-defunct-tid-to-get-detach.patch @@ -0,0 +1,75 @@ +From e747d0456adc080a1d31fb653bda9dc491795c80 Mon Sep 17 00:00:00 2001 +From: Jan Stancek +Date: Sun, 16 Jun 2019 11:14:16 +0200 +Subject: [PATCH] syscalls/tgkill03: wait for defunct tid to get detached + +Case where defunct tid is used has been observed to sporadically fail: + tgkill03.c:96: FAIL: Defunct tid should have failed with ESRCH: SUCCESS + +glibc __pthread_timedjoin_ex() waits for CLONE_CHILD_CLEARTID to clear tid, +and then resumes. Kernel clears it (glibc pd->tid) at: + do_exit + exit_mm + mm_release + put_user(0, tsk->clear_child_tid); + +but kernel tid is still valid, presumably until: + release_task + __exit_signal + __unhash_process + detach_pid + +To avoid race wait until /proc//task/ disappears. + +Signed-off-by: Jan Stancek +Reviewed-by: Li Wang +Acked-by: Sumit Garg + +Upstream-Status: Backport +[https://github.com/linux-test-project/ltp/commit/e747d0456adc080a1d31fb653bda9dc491795c80] + +Signed-off-by: He Zhe +--- + testcases/kernel/syscalls/tgkill/tgkill03.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/testcases/kernel/syscalls/tgkill/tgkill03.c b/testcases/kernel/syscalls/tgkill/tgkill03.c +index f5bbdc5..593a217 100644 +--- a/testcases/kernel/syscalls/tgkill/tgkill03.c ++++ b/testcases/kernel/syscalls/tgkill/tgkill03.c +@@ -7,6 +7,7 @@ + + #include + #include ++#include + #include + + #include "tst_safe_pthread.h" +@@ -42,6 +43,7 @@ static void setup(void) + { + sigset_t sigusr1; + pthread_t defunct_thread; ++ char defunct_tid_path[PATH_MAX]; + + sigemptyset(&sigusr1); + sigaddset(&sigusr1, SIGUSR1); +@@ -55,8 +57,9 @@ static void setup(void) + TST_CHECKPOINT_WAIT(0); + + SAFE_PTHREAD_CREATE(&defunct_thread, NULL, defunct_thread_func, NULL); +- + SAFE_PTHREAD_JOIN(defunct_thread, NULL); ++ sprintf(defunct_tid_path, "/proc/%d/task/%d", getpid(), defunct_tid); ++ TST_RETRY_FN_EXP_BACKOFF(access(defunct_tid_path, R_OK), -1, 15); + } + + static void cleanup(void) +@@ -108,4 +111,5 @@ static struct tst_test test = { + .setup = setup, + .cleanup = cleanup, + .test = run, ++ .timeout = 20, + }; +-- +2.7.4 + diff --git a/meta/recipes-extended/ltp/ltp_20190517.bb b/meta/recipes-extended/ltp/ltp_20190517.bb index c62f2618b5..f6c7de62dd 100644 --- a/meta/recipes-extended/ltp/ltp_20190517.bb +++ b/meta/recipes-extended/ltp/ltp_20190517.bb @@ -43,6 +43,7 @@ SRC_URI = "git://github.com/linux-test-project/ltp.git \ file://0012-getrlimit03-adjust-a-bit-of-code-to-compatiable-with.patch \ file://0001-Add-configure-time-check-for-getdents-getdents64-API.patch \ file://0002-check-for-RES_USE_INET6-during-configure.patch \ + file://0001-syscalls-tgkill03-wait-for-defunct-tid-to-get-detach.patch \ " S = "${WORKDIR}/git" -- cgit 1.2.3-korg