kill11: Skip pipe-based core dumps per signal
PATCH v2 1/1 kill11: Skip pipe-based core dumps per signal
kill11 verifies the signal and core dump bit reported to the waiting parent.
When /proc/sys/kernel/core_pattern starts with '|', core dumps are handled by a userspace helper such as systemd-coredump. In such setups the test may hang waiting for children that are blocked in the core dump path instead of testing the wait status itself.
However, only signals with dumps_core=1 (SIGQUIT, SIGILL, SIGABRT, etc.) actually trigger core dump handling. Signals with dumps_core=0 (SIGHUP, SIGKILL, SIGTERM, SIGPIPE, etc.) exit immediately without touching the core dump path.
Detect pipe-based core dumps in setup() and skip only the affected test cases (those with dumps_core=1) in verify_kill(). This preserves test coverage for non-core-dumping signals while preventing hangs.
---
Changes since v1:
- Skip only core-dumping signals (dumps_core=1) instead of all test cases
- Keep core_pattern detection in setup(), move skip decision to verify_kill()
- Preserve coverage for non-core-dumping signals
testcases/kernel/syscalls/kill/kill11.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
testcases/kernel/syscalls/kill/kill11.c +17 -0
@@ -25,6 +25,8 @@#include "tst_test.h" +static bool pipe_based_coredump; + static struct tcase { int sig; int dumps_core;
@@ -64,6 +66,12 @@ static void verify_kill(unsigned int n)int nsig, status;struct tcase *tc = &tcases[n]; +if (tc->dumps_core && pipe_based_coredump) { +tst_res (TCONF ,"%s: pipe-based core dump handler active" , +tst_strsig (tc->sig)); +return ; + } + pid =SAFE_FORK ();if (!pid)pause ();
@@ -105,6 +113,7 @@ static void verify_kill(unsigned int n)static void setup (void ) {struct rlimit rlim; +char core_pattern[256 ];SAFE_GETRLIMIT (RLIMIT_CORE , &rlim);
@@ -121,6 +130,14 @@ static void setup(void) rlim.rlim_cur =MIN_RLIMIT_CORE ;SAFE_SETRLIMIT (RLIMIT_CORE , &rlim); } + +/* +* If core_pattern pipes core dumps to a user-space helper, the child may +* remain in the core dump path until the helper completes. Store the +* result and skip only signals that actually request a core dump. +*/ +SAFE_FILE_SCANF ("/proc/sys/kernel/core_pattern" ,"%255s" , core_pattern); + pipe_based_coredump = (core_pattern[0 ] =='|' ); }static struct tst_test test = {
--
2.55.0
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Jan,
Quoted 1 line · Jan Polensky
kill11: Skip pipe-based core dumps per signal
Verdict - Reviewed
---
Note:
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
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Alternative we may change the core pattern for the duration of the test. Does this patch fixes the issue for you?
testcases/kernel/syscalls/kill/kill11.c +5 -0
@@ -126,7 +126,12 @@ static void setup(void)static struct tst_test test = { .needs_tmpdir =1 , .forks_child =1 , + .needs_root =1 , .setup = setup, .tcnt =ARRAY_SIZE (tcases), .test = verify_kill, + .save_restore = (const struct tst_path_val []) { + {PATH_KERN_CORE_PATTERN ,"core" ,TST_SR_TBROK }, + {} + } };
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Cyril,
testcases/kernel/syscalls/kill/kill11.c static void setup(void) · line 129
Quoted 13 lines
Hi!
Alternative we may change the core pattern for the duration of the test. Does this patch fixes the issue for you?testcases/kernel/syscalls/kill/kill11.c +1
-0@@ -126,7 +126,12 @@ static void setup(void)static struct tst_test test = { .needs_tmpdir =1 , .forks_child =1 , + .needs_root =1 ,
I don't know if it's a good idea to switch to privileged user, since we would remove the test from parallel execution.
Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 15 lines
testcases/kernel/syscalls/kill/kill11.c static void setup(void) · line 129
Quoted 12 lines
Alternative we may change the core pattern for the duration of the test. Does this patch fixes the issue for you?
testcases/kernel/syscalls/kill/kill11.c +1
-0@@ -126,7 +126,12 @@ static void setup(void)static struct tst_test test = { .needs_tmpdir =1 , .forks_child =1 , + .needs_root =1 ,I don't know if it's a good idea to switch to privileged user, since we would remove the test from parallel execution.
Well either we do that, or we skip the signals that dump core when we are dumping into the pipe.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 2 lines
Well either we do that, or we skip the signals that dump core when we are dumping into the pipe.
To me it looks good to skip the signals which are not allowing child to be killed after coredump. It's a systemd feature we can't workaround in this case.
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 6 lines
Quoted 2 lines
Well either we do that, or we skip the signals that dump core when we are dumping into the pipe.
To me it looks good to skip the signals which are not allowing child to be killed after coredump. It's a systemd feature we can't workaround in this case.
Thinking of it once more, I wonder what exactly fails in the systemd-coredump case. I guess that it may delay the test execution a bit but the crashed process should eventualy quit and the test wait() call should collect it. If that wasn't the case systemd-coredump would break one of the fundamentals of UNIX process management.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 8 lines
Hi!
Quoted 6 lines
Quoted 2 lines
Well either we do that, or we skip the signals that dump core when we are dumping into the pipe.
To me it looks good to skip the signals which are not allowing child to be killed after coredump. It's a systemd feature we can't workaround in this case.
Quoted 5 lines
Thinking of it once more, I wonder what exactly fails in the systemd-coredump case. I guess that it may delay the test execution a bit but the crashed process should eventualy quit and the test
wait()call should collect it. If that wasn't the case systemd-coredump would break one of the fundamentals of UNIX process management.
Let's forget about systemd for a second.
The problem is that by using pause() that is not draining the buffer we never ends the piped user-space helper. The default behaviour for a piped helper is that kernel collect the coredump until helper drains the pipe.
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 24 lines · Cyril Hrubis
Hi!
Alternative we may change the core pattern for the duration of the test. Does this patch fixes the issue for you?testcases/kernel/syscalls/kill/kill11.c +5
-1@@ -126,7 +126,12 @@ static void setup(void)static struct tst_test test = { .needs_tmpdir =1 , .forks_child =1 , + .needs_root =1 , .setup = setup, .tcnt =ARRAY_SIZE (tcases), .test = verify_kill, + .save_restore = (const struct tst_path_val []) { + {PATH_KERN_CORE_PATTERN ,"core" ,TST_SR_TBROK }, + {} + } }; --
Quoted 2 lines
Cyril Hrubis
[email protected]
Hi Cyril,
yes, this patch fixes the issue completely for me.
I tested it on both x86_64 and s390 with different configurations and could no longer reproduce the failures.
Using a non-pipe core_pattern during the test is a good solution for my setup.
Regards,
Jan
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 11 lines
Quoted 5 lines
Thinking of it once more, I wonder what exactly fails in the systemd-coredump case. I guess that it may delay the test execution a bit but the crashed process should eventualy quit and the test
wait()call should collect it. If that wasn't the case systemd-coredump would break one of the fundamentals of UNIX process management.Let's forget about systemd for a second.
The problem is that by using
pause()that is not draining the buffer we never ends the piped user-space helper. The default behaviour for a piped helper is that kernel collect the coredump until helper drains the pipe.
Which would mean that the system this is failing on is mis-configured at best. I've tested this on Leap 16.0 that uses systemd-coredump and everything works fine there.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp