This adresses a bug in libcap_psx_test, one of the ptests. libcap_psx_test checks that capability state remains consistent when concurrent changes to process capability state are made across multiple threads that each perform a fork().
libcap_psx_test outputs that it passed, but leaves a child process in an S state after executing. A fix was found by changing the exit() in a child process to _exit, avoiding the exit handlers that were causing the deadlock. Signed-off-by: Kris Gavvala <[email protected]> --- ...1-libcap-fix-hang-in-libcap_psx_test.patch | 47 +++++++++++++++++++ meta/recipes-support/libcap/libcap_2.78.bb | 1 + 2 files changed, 48 insertions(+) create mode 100644 meta/recipes-support/libcap/files/0001-libcap-fix-hang-in-libcap_psx_test.patch diff --git a/meta/recipes-support/libcap/files/0001-libcap-fix-hang-in-libcap_psx_test.patch b/meta/recipes-support/libcap/files/0001-libcap-fix-hang-in-libcap_psx_test.patch new file mode 100644 index 0000000000..353d7358f2 --- /dev/null +++ b/meta/recipes-support/libcap/files/0001-libcap-fix-hang-in-libcap_psx_test.patch @@ -0,0 +1,47 @@ +From a51273125b90157de70ae2615a91f82c1775615b Mon Sep 17 00:00:00 2001 +From: Kris Gavvala <[email protected]> +Date: Fri, 12 Jun 2026 14:55:11 -0700 +Subject: [PATCH] libcap: fix hang in libcap_psx_test + +When running libcap_psx_test on some non-x86-64 targets, a hang occurs. +In thread_fork_exit(), the forked child calls exit(0), which invokes exit +handlers and blocks waiting for an internal lock. + +Use of exit() is unsafe in a forked child of a multithreaded process because +of the internal handlers that can causing blocking. + +This commit replaces exit() with _exit() in the child to bypass +exit handling and prevent a deadlock from occuring. + +Signed-off-by: Kris Gavvala <[email protected]> +Upstream-Status: Submitted [[email protected]] +Upstream tracking: [https://github.com/AndrewGMorgan/libcap_mirror/issues/12#issue-4652587116] + +--- + tests/libcap_psx_test.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/tests/libcap_psx_test.c b/tests/libcap_psx_test.c +index 58a13ec..693aeb5 100644 +--- a/tests/libcap_psx_test.c ++++ b/tests/libcap_psx_test.c +@@ -24,13 +24,13 @@ static void *thread_fork_exit(void *data) { + if (pid == 0) { + if (cap_prctlw(PR_SET_KEEPCAPS, !start, 0, 0, 0, 0) != 0) { + perror("failed to set proc"); +- exit(1); ++ _exit(1); + } + if (cap_prctlw(PR_GET_KEEPCAPS, 0, 0, 0, 0, 0) == start) { + perror("failed to have set forked proc"); +- exit(1); ++ _exit(1); + } +- exit(0); ++ _exit(0); + } + int res; + if (waitpid(pid, &res, 0) != pid || res != 0) { +-- +2.49.0 + diff --git a/meta/recipes-support/libcap/libcap_2.78.bb b/meta/recipes-support/libcap/libcap_2.78.bb index d91ece4aaf..54c965a130 100644 --- a/meta/recipes-support/libcap/libcap_2.78.bb +++ b/meta/recipes-support/libcap/libcap_2.78.bb @@ -18,6 +18,7 @@ SRC_URI:append:class-nativesdk = " \ " SRC_URI:append = " \ file://run-ptest \ + file://0001-libcap-fix-hang-in-libcap_psx_test.patch \ " SRC_URI[sha256sum] = "0d621e562fd932ccf67b9660fb018e468a683d7b827541df27813228c996bb11" -- 2.49.0
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#238648): https://lists.openembedded.org/g/openembedded-core/message/238648 Mute This Topic: https://lists.openembedded.org/mt/119784303/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
