Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 595492 - sys-process/cronbase-0.3.7-r1 with apps-shells/bash-4.4: /usr/sbin/run-crons: line 59: warning: command substitution: ignored null byte in input
Summary: sys-process/cronbase-0.3.7-r1 with apps-shells/bash-4.4: /usr/sbin/run-crons:...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Tobias Klausmann (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 595276
  Show dependency tree
 
Reported: 2016-09-29 02:36 UTC by Craig Andrews
Modified: 2016-11-15 06:07 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Craig Andrews gentoo-dev 2016-09-29 02:36:45 UTC
When running under bash 4.4 sys-process/cronbase has a bug that causes the warning:

/usr/sbin/run-crons: line 59: warning: command substitution: ignored null byte in input
/usr/sbin/run-crons: line 60: warning: command substitution: ignored null byte in input

...to repeat many times.
Comment 1 Felix Janda 2016-09-29 11:12:40 UTC
How about

--- run-crons-0.3.7
+++ run-crons-0.3.7-r1
@@ -56,9 +56,7 @@
 
 		# This is better than kill -0 because we can verify that it's really
 		# another run-crons process.
-		cmdline1=$(cat "/proc/${cronpid}/cmdline" 2>/dev/null) || :
-		cmdline2=$(cat /proc/$$/cmdline)
-		if [ "${cmdline1}" = "${cmdline2}" ] ; then
+		if ! cmp "/proc/${cronpid}/cmdline" /proc/$$/cmdline ; then
 			# Whoa, another run-crons is really running.
 			return 1
 		fi
Comment 2 Craig Andrews gentoo-dev 2016-09-29 17:31:32 UTC
(In reply to Felix Janda from comment #1)
> How about
> 
> --- run-crons-0.3.7
> +++ run-crons-0.3.7-r1
> @@ -56,9 +56,7 @@
>  
>  		# This is better than kill -0 because we can verify that it's really
>  		# another run-crons process.
> -		cmdline1=$(cat "/proc/${cronpid}/cmdline" 2>/dev/null) || :
> -		cmdline2=$(cat /proc/$$/cmdline)
> -		if [ "${cmdline1}" = "${cmdline2}" ] ; then
> +		if ! cmp "/proc/${cronpid}/cmdline" /proc/$$/cmdline ; then
>  			# Whoa, another run-crons is really running.
>  			return 1
>  		fi

That seems to work most of the time, but sometimes, I'm getting:
cmp: /proc/28440/cmdline: No such file or directory
Comment 3 Andrejs Eigus 2016-09-30 05:50:01 UTC
I am having the same issue.
Comment 4 Tobias Klausmann (RETIRED) gentoo-dev 2016-09-30 07:36:00 UTC
I fixed it in commit 7c266d7a1854b3b1b543fb35036d3e4e6c3135cf:

diff --git a/sys-process/cronbase/cronbase-0.3.7-r1.ebuild b/sys-process/cronbase/cronbase-0.3.7-r2.ebuild
similarity index 100%
rename from sys-process/cronbase/cronbase-0.3.7-r1.ebuild
rename to sys-process/cronbase/cronbase-0.3.7-r2.ebuild
diff --git a/sys-process/cronbase/files/run-crons-0.3.7 b/sys-process/cronbase/files/run-crons-0.3.7
index c661c77..c5f2d9c 100755
--- a/sys-process/cronbase/files/run-crons-0.3.7
+++ b/sys-process/cronbase/files/run-crons-0.3.7
@@ -56,8 +56,10 @@ grab_lock() {
 
                # This is better than kill -0 because we can verify that it's really
                # another run-crons process.
-               cmdline1=$(cat "/proc/${cronpid}/cmdline" 2>/dev/null) || :
-               cmdline2=$(cat /proc/$$/cmdline)
+               # The tr call deletes null bytes so newer bash versions do not complain
+               # about them.
+               cmdline1=$(tr -d '\0'  < "/proc/${cronpid}/cmdline" 2>/dev/null) || :
+               cmdline2=$(tr -d '\0'  < /proc/$$/cmdline)
                if [ "${cmdline1}" = "${cmdline2}" ] ; then
                        # Whoa, another run-crons is really running.
                        return 1
Comment 5 Craig Andrews gentoo-dev 2016-09-30 13:41:19 UTC
I'm still getting messages like this:
/usr/sbin/run-crons: line 61: /proc/6450/cmdline: No such file or directory

So I suspect there's more work to do.
Comment 6 Tobias Klausmann (RETIRED) gentoo-dev 2016-09-30 14:08:40 UTC
(In reply to candrews from comment #5)
> I'm still getting messages like this:
> /usr/sbin/run-crons: line 61: /proc/6450/cmdline: No such file or directory
> 
> So I suspect there's more work to do.

Can you check which of the two cmdline=... lines in /usr/sbin/run-crons is #61? I have a suspicion, but I want to make sure I get this right.
Comment 7 Craig Andrews gentoo-dev 2016-09-30 14:10:08 UTC
Line 61 is:
cmdline1=$(tr -d '\0'  < "/proc/${cronpid}/cmdline" 2>/dev/null) || :
Comment 8 Tobias Klausmann (RETIRED) gentoo-dev 2016-09-30 14:11:21 UTC
(In reply to Tobias Klausmann from comment #6)
> (In reply to candrews from comment #5)
> > I'm still getting messages like this:
> > /usr/sbin/run-crons: line 61: /proc/6450/cmdline: No such file or directory
> > 
> > So I suspect there's more work to do.
> 
> Can you check which of the two cmdline=... lines in /usr/sbin/run-crons is
> #61? I have a suspicion, but I want to make sure I get this right.

Nevermind, this seems to be a case of a stale lockfile (PID X is in it, but there is no PID X running). I'll have to think about this one. Adding more checks just makes the whole thing racier and racier.
Comment 9 Tobias Klausmann (RETIRED) gentoo-dev 2016-09-30 14:18:20 UTC
I think I have an admittedly ugly solution in commit f97ae47b8a4dd7b4959a019adf148390e3a182cf, aka -r3.
Comment 10 Craig Andrews gentoo-dev 2016-10-01 22:22:07 UTC
(In reply to Tobias Klausmann from comment #9)
> I think I have an admittedly ugly solution in commit
> f97ae47b8a4dd7b4959a019adf148390e3a182cf, aka -r3.

I'm still intermittently seeing the same message (same line, 61) on -r3 unfortunately.
Comment 11 Tobias Klausmann (RETIRED) gentoo-dev 2016-10-02 08:49:39 UTC
(In reply to candrews from comment #10)
> (In reply to Tobias Klausmann from comment #9)
> > I think I have an admittedly ugly solution in commit
> > f97ae47b8a4dd7b4959a019adf148390e3a182cf, aka -r3.
> 
> I'm still intermittently seeing the same message (same line, 61) on -r3
> unfortunately.

I switched the lines to using sed, so we can redirect the error message cleanly. Version -r4 should fix this once and for all.
Comment 12 Craig Andrews gentoo-dev 2016-10-02 21:17:04 UTC
(In reply to Tobias Klausmann from comment #11)
> (In reply to candrews from comment #10)
> > (In reply to Tobias Klausmann from comment #9)
> > > I think I have an admittedly ugly solution in commit
> > > f97ae47b8a4dd7b4959a019adf148390e3a182cf, aka -r3.
> > 
> > I'm still intermittently seeing the same message (same line, 61) on -r3
> > unfortunately.
> 
> I switched the lines to using sed, so we can redirect the error message
> cleanly. Version -r4 should fix this once and for all.

-r4 made the problem worse. Now every time I get multiple instances of this message:
/usr/sbin/run-crons: line 61: warning: command substitution: ignored null byte in input
Comment 13 Tobias Klausmann (RETIRED) gentoo-dev 2016-10-03 07:34:33 UTC
Can you try replacing the \0 on lines 61 and 62 with \x0 and see if that fixes it for you?
Comment 14 Dan Goodliffe 2016-10-03 14:22:32 UTC
\x0 works for me... but just a thought...

if diff -qs /proc/{${cronpid},$$}/cmdline > /dev/null ; then

Is that easier than trying to get sed to fix the problem?
Comment 15 Tobias Klausmann (RETIRED) gentoo-dev 2016-10-03 15:10:52 UTC
(In reply to Dan Goodliffe from comment #14)
> \x0 works for me... but just a thought...
> 
> if diff -qs /proc/{${cronpid},$$}/cmdline > /dev/null ; then
> 
> Is that easier than trying to get sed to fix the problem?

That is an an excellent idea. I will do some tests tonight and use diff if that goes swimmingly.
Comment 16 Tobias Klausmann (RETIRED) gentoo-dev 2016-10-03 17:20:30 UTC
I put Dan's suggestion in -r5 -- thanks again!

candrews: does this fix matters for you?
Comment 17 Craig Andrews gentoo-dev 2016-10-03 20:02:54 UTC
(In reply to Tobias Klausmann from comment #13)
> Can you try replacing the \0 on lines 61 and 62 with \x0 and see if that
> fixes it for you?

This change fixes the problem for me. Woo hoo!
Comment 18 SpanKY gentoo-dev 2016-11-15 06:07:05 UTC
(In reply to Tobias Klausmann from comment #15)

that syntax is a bash extension.  we also don't want to rely on diff or cmp because those are provided by diffutils rather than more basic/common packages.

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b11e8d8b4555479dce4054aca1feffb06c0066e6