bug#51793: FAIL: tests/misc/env-signal-handler

2021-11-13 Thread Pádraig Brady

On 13/11/2021 09:46, Andreas Schwab wrote:

On Nov 12 2021, Pádraig Brady wrote:


I've never seen this, and I can't see the race.


There is an obvious race: if env needs more than .1 seconds to set the
SIGINT handler.


Indeed.

That fits the pattern where we need a certain delay to pass.
So we can use our retry_delay_ helper here.
I'll apply the attached later.

thanks,
Pádraig
From dd460b0a7ac029a1809ca2ef363701b431e613be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= 
Date: Sat, 13 Nov 2021 12:15:17 +
Subject: [PATCH] tests: avoid rare false failure in env-signal-handler.sh

* tests/misc/env-signal-handler.sh: Use retry_delay_ to
avoid a false failure under load, where env hasn't setup
the SIGINT handling before timeout(1) sends the SIGINT.
Fixes https://bugs.gnu.org/51793
---
 tests/misc/env-signal-handler.sh | 64 +---
 1 file changed, 26 insertions(+), 38 deletions(-)

diff --git a/tests/misc/env-signal-handler.sh b/tests/misc/env-signal-handler.sh
index aa6ec8dac..c4179fe9e 100755
--- a/tests/misc/env-signal-handler.sh
+++ b/tests/misc/env-signal-handler.sh
@@ -82,62 +82,50 @@ compare /dev/null err4 || fail=1
 # env test - block signal handler
 env --block-signal true || fail=1
 
+env_ignore_delay_()
+{
+  local delay="$1"
+
+  # The first 'env' is just to ensure timeout is not a shell built-in.
+  env timeout --verbose --kill-after=.1 --signal=INT $delay \
+env $env_opt \
+sleep 10 > /dev/null 2>outt
+  # check only the first two lines from stderr, which are printed by timeout.
+  # (operating systems might add more messages, like "killed").
+  sed -n '1,2p' outt > out || framework_failure_
+  compare exp out
+}
+
 # Baseline test - ignore signal handler
 # -
-# Kill 'sleep' after 1 second with SIGINT - it should terminate (as SIGINT's
-# default action is to terminate a program).
-# (The first 'env' is just to ensure timeout is not the shell's built-in.)
-env timeout --verbose --kill-after=.1 --signal=INT .1 \
-sleep 10 > /dev/null 2>err5
-
-printf "timeout: sending signal INT to command 'sleep'\n" > exp-err5 \
-|| framework_failure_
-
-compare exp-err5 err5 || fail=1
-
+# Kill 'sleep' after 1 second with SIGINT - it should terminate
+# (as SIGINT's default action is to terminate a program).
+cat <<\EOF >exp || framework_failure_
+timeout: sending signal INT to command 'env'
+EOF
+env_opt='' retry_delay_ env_ignore_delay_ .1 6 || fail=1
 
 # env test - ignore signal handler
 # 
-# Use env to silence (ignore) SIGINT - "seq" should continue running
+# Use env to silence (ignore) SIGINT - "sleep" should continue running
 # after timeout sends SIGINT, and be killed after 1 second using SIGKILL.
-
-cat>exp-err6  /dev/null 2>err6t
-
-# check only the first two lines from stderr, which are printed by timeout.
-# (operating systems might add more messages, like "killed").
-sed -n '1,2p' err6t > err6 || framework_failure_
-
-compare exp-err6 err6 || fail=1
-
+env_opt='--ignore-signal=INT' retry_delay_ env_ignore_delay_ .1 6 || fail=1
 
 # env test - ignore signal handler (2)
 # 
-# Repeat the previous test with "--ignore-signals" and no signal names,
+# Repeat the previous test with "--ignore-signal" and no signal names,
 # i.e., all signals.
-
-env timeout --verbose --kill-after=.1 --signal=INT .1 \
-env --ignore-signal \
-sleep 10 > /dev/null 2>err7t
-
-# check only the first two lines from stderr, which are printed by timeout.
-# (operating systems might add more messages, like "killed").
-sed -n '1,2p' err7t > err7 || framework_failure_
-
-compare exp-err6 err7 || fail=1
-
+env_opt='--ignore-signal' retry_delay_ env_ignore_delay_ .1 6 || fail=1
 
 # env test --list-signal-handling
 env --default-signal --ignore-signal=INT --list-signal-handling true \
   2> err8t || fail=1
 sed 's/(.*)/()/' err8t > err8 || framework_failure_
-env printf 'INT(): IGNORE\n' > exp-err8
+env printf 'INT(): IGNORE\n' > exp-err8 || framework_failure_
 compare exp-err8 err8 || fail=1
 
 
-- 
2.26.2



bug#51793: FAIL: tests/misc/env-signal-handler

2021-11-13 Thread Andreas Schwab
On Nov 12 2021, Pádraig Brady wrote:

> I've never seen this, and I can't see the race.

There is an obvious race: if env needs more than .1 seconds to set the
SIGINT handler.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."





bug#51793: FAIL: tests/misc/env-signal-handler

2021-11-13 Thread Andreas Schwab
https://build.opensuse.org/package/live_build_log/home:Andreas_Schwab:Factory/coreutils/s/s390x

./tests/misc/env-signal-handler.sh: line 91:  8508 Killed  env 
timeout --verbose --kill-after=.1 --signal=INT .1 sleep 10 > /dev/null 2> err5
--- exp-err52021-11-13 09:14:29.837716890 +
+++ err52021-11-13 09:14:29.767716890 +
@@ -1 +1,2 @@
 timeout: sending signal INT to command 'sleep'
+timeout: sending signal KILL to command 'sleep'
./tests/misc/env-signal-handler.sh: line 111:  8525 Killed  env 
timeout --verbose --kill-after=.1 --signal=INT .1 env --ignore-signal=INT sleep 
10 > /dev/null 2> err6t
./tests/misc/env-signal-handler.sh: line 127:  8551 Killed  env 
timeout --verbose --kill-after=.1 --signal=INT .1 env --ignore-signal sleep 10 
> /dev/null 2> err7t
FAIL tests/misc/env-signal-handler.sh (exit status: 1)

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."





bug#51793: FAIL: tests/misc/env-signal-handler

2021-11-13 Thread Andreas Schwab
On Nov 12 2021, Pádraig Brady wrote:

> On 12/11/2021 19:25, Andreas Schwab wrote:
>> --- exp-err6   2021-11-11 22:58:04.360716802 +
>> +++ err6   2021-11-11 22:58:04.752716821 +
>> @@ -1,2 +1 @@
>>   timeout: sending signal INT to command 'env'
>> -timeout: sending signal KILL to command 'env'
>
> The above is for the previous command not the following.
>
>> ./tests/misc/env-signal-handler.sh: line 127: 26396 Killed  
>> env timeout --verbose --kill-after=.1 --signal=INT .1 env --ignore-signal 
>> sleep 10 > /dev/null 2> err7t
>> FAIL tests/misc/env-signal-handler.sh (exit status: 1)
>
> Could you paste a bit more context from the previous command.

This is the complete output.

> I presume this is a race that you're seeing rarely.

Yes.

> I've never seen this, and I can't see the race.

Try adding load to the system.

> What file system, kernel, shell are you using.

https://build.opensuse.org/package/live_build_log/home:Andreas_Schwab:Factory/coreutils/r/riscv64

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."





bug#51793: FAIL: tests/misc/env-signal-handler

2021-11-12 Thread Pádraig Brady

On 12/11/2021 19:25, Andreas Schwab wrote:

--- exp-err6   2021-11-11 22:58:04.360716802 +
+++ err6   2021-11-11 22:58:04.752716821 +
@@ -1,2 +1 @@
  timeout: sending signal INT to command 'env'
-timeout: sending signal KILL to command 'env'


The above is for the previous command not the following.


./tests/misc/env-signal-handler.sh: line 127: 26396 Killed  env 
timeout --verbose --kill-after=.1 --signal=INT .1 env --ignore-signal sleep 10 > 
/dev/null 2> err7t
FAIL tests/misc/env-signal-handler.sh (exit status: 1)


Could you paste a bit more context from the previous command.
Specifically I'm wondering if the "Killed" message was displayed
(i.e. if the SIGKILL was actually sent).

I presume this is a race that you're seeing rarely.
I've never seen this, and I can't see the race.

What might be happening is the "sending signal KILL..."
message sent to stderr, is in a buffer somewhere,
which is dropped upon processing of SIGKILL.

What file system, kernel, shell are you using.

cheers,
Pádraig






bug#51793: FAIL: tests/misc/env-signal-handler

2021-11-12 Thread Andreas Schwab
--- exp-err6   2021-11-11 22:58:04.360716802 +
+++ err6   2021-11-11 22:58:04.752716821 +
@@ -1,2 +1 @@
 timeout: sending signal INT to command 'env'
-timeout: sending signal KILL to command 'env'
./tests/misc/env-signal-handler.sh: line 127: 26396 Killed  env 
timeout --verbose --kill-after=.1 --signal=INT .1 env --ignore-signal sleep 10 
> /dev/null 2> err7t
FAIL tests/misc/env-signal-handler.sh (exit status: 1)

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."