Bug 198140

Summary: ps truncates line to 2048 characters
Product: Red Hat Enterprise Linux 4 Reporter: Bastien Nocera <bnocera>
Component: procpsAssignee: Karel Zak <kzak>
Status: CLOSED ERRATA QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.0CC: jturner, kmori, tao
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: RHBA-2007-0237 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-05-01 17:40:42 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 176344, 198868    

Description Bastien Nocera 2006-07-10 09:57:05 UTC
Problem also exists in procps-3.2.3-8.4

+++ This bug was initially created as a clone of Bug #134516 +++

Description of problem:
ps auxwwww (even with many more 'w's) will truncate the command-line
of the program to 2048 characters.
The real command-line is shown in /proc:
grep -a java /proc/*/cmdline

Version-Release number of selected component (if applicable):
procps-2.0.17-10

How reproducible:
Every time

Steps to Reproduce:
1. Attached a test case below
2. Compile and run it
3. Compare output in /proc and output of ps

-- Additional comment from bnocera on 2004-10-04 06:52 EST --
Created an attachment (id=104713)
long-name.c


-- Additional comment from bnocera on 2004-10-04 06:55 EST --
Note that the code to change the argv is from:
http://lightconsulting.com/~thalakan/process-title-notes.html

-- Additional comment from bnocera on 2004-10-04 11:34 EST --
There appears to be the customer's name in the test case. Better not
have this public.

-- Additional comment from kzak on 2004-10-06 06:36 EST --
Hmm.. it's interesting:

$ ps -a -o command= | grep java | head -n 1 | tr -d "\n" | wc -c
1515
$ cat /proc/762/cmdline | wc -c
1515

$ uname -r
2.6.8-1.521

It's FC2 and long-name.c sets 3725 bytes to argv[0]. In this case a
problem is not in the procps.

-- Additional comment from bnocera on 2004-10-06 06:50 EST --
Agreed, but the problem is in procps on a RHEL3 system, as the data is
correct is /proc.

-- Additional comment from kzak on 2004-10-22 04:49 EST --
Created an attachment (id=105638)
Bugfix patch.

This patch fix the problem with truncated output lines to 2048 characters in
procps 2.0.17. The problem will fixed in the next update (RHEL3-U5).

-- Additional comment from jturner on 2004-12-16 08:10 EST --
Looks good with 2.0.17-13.  Prepping for the next errata update.

-- Additional comment from kzak on 2004-12-16 09:48 EST --
Sorry, this going to RHEL3-U4 (and not to U5 as I expected).

-- Additional comment from flanagan on 2004-12-21 14:09 EST --

An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2004-544.html


-- Additional comment from mwesley on 2004-12-22 09:56 EST --
Fixed in an errata.  Removing from U5 blocker list.

-- Additional comment from bnocera on 2006-04-28 10:38 EST --
The problem still exists when the command-line is exactly 2047 characters
because of an off-by-one error in the procps-2.0.17-longcmd.patch patch.

in readproc.c:
        /* read whole file into a memory buffer, allocating as we go */
       while ((n = read(fd, buf, sizeof buf - 1)) > 0) {
               if (n < BUF_LEN)
                       end_of_file = 1;

BUF_LEN is *always* greater than n, as BUF_LEN is 2048, and we read up to 2048-1
characters.

-- Additional comment from kzak on 2006-04-28 11:17 EST --
Your code is without the patch. I see code:

        while ((n = read(fd, buf, sizeof buf - 1)) > 0) {
                if (n < (int) (sizeof buf - 1))
                        end_of_file = 1;



-- Additional comment from bnocera on 2006-04-28 11:35 EST --
Seems I got that wrong, here are the 2 files for the test case.

$ ./test_2047.sh
<snip>

$ ps auxwwww
<snip>
bnocera    385  0.0  0.1  4640  992 pts/9    S+   16:40   0:00 [sh]
<snip>

Instead of the whole command-line.

-- Additional comment from bnocera on 2006-04-28 11:36 EST --
Created an attachment (id=128361)
test_2047.sh


-- Additional comment from bnocera on 2006-04-28 11:37 EST --
Created an attachment (id=128362)
test.sh


-- Additional comment from kmori on 2006-05-23 00:34 EST --
Fujitsu is asking what the current status on this.
Could engineer please update anything here ? And could we get the fix in RHEL3 ?

-- Additional comment from kmori on 2006-06-21 23:24 EST --
Is this issue to be WONTFIX in RHEL3 ? Or do we have any chance to release
errata in RHEL3 via fastrack or else ?


-- Additional comment from kzak on 2006-06-23 11:10 EST --
Bastien, 
http://people.redhat.com/kzak/procps/ps-test-truncates.tar.gz

$ tar zxvf ps-test-truncates.tar.gz
ps-test-truncates/
ps-test-truncates/run.sh
ps-test-truncates/ps_truncates.sh

$ cd ps-test-truncates/

$ ./run.sh
cmdline size (org=2029, new=2029) .... PASS

$ rpm -q procps
procps-2.0.17-13.7

(the latest version is 2.0.17-13.10)

Note: you can manually add "ps auxwwww" to the ps_truncates.sh srcipt and you
will see real output. I don't see there any problem.

-- Additional comment from kmori on 2006-07-03 00:07 EST --
Created an attachment (id=131872)
Testcase

Karel,

Please try this testcase under /tmp directory. You can see this issue with the
latest procps package.
[root@dhcp100 root]# tar zxvf ps-test-truncates.tar.gz -C /tmp/
ps-test-truncates/
ps-test-truncates/run.sh
ps-test-truncates/ps_truncates.sh
[root@dhcp100 root]# cd /tmp/ps-test-truncates/
[root@dhcp100 ps-test-truncates]# ./run.sh
cmdline size (org=1995, new=	 18) .... FAILED
===output===
[ps_truncates.sh]
============
[root@dhcp100 ps-test-truncates]# rpm -q procps
procps-2.0.17-13.10


-- Additional comment from bnocera on 2006-07-10 04:31 EST --
Keiichi, I don't see this here.
# ./run.sh
cmdline size (org=1995, new=   1995) .... PASS
# rpm -q procps
procps-2.0.17-13.7


-- Additional comment from kmori on 2006-07-10 04:41 EST --
Bastien,

Where did you execute a testcase ? You need to run my testcase in comment#20
under /tmp/ps-test-truncates directory.

I have seen this issue both with procps-2.0.17-13.10 and procps-2.0.17-13.7.

[root@dhcp100 ps-test-truncates]# rpm -q procps
procps-2.0.17-13.7
[root@dhcp100 ps-test-truncates]# pwd
/tmp/ps-test-truncates
[root@dhcp100 ps-test-truncates]# ./run.sh
cmdline size (org=1995, new=     18) .... FAILED
===output===
[ps_truncates.sh]
============
[root@dhcp100 ps-test-truncates]# up2date --update

Fetching Obsoletes list for channel: rhel-i386-as-3...

Fetching Obsoletes list for channel: rhel-i386-as-3-extras...

Fetching Obsoletes list for channel: rhn-tools-rhel-3-as-i386...

Fetching Obsoletes list for channel: rhel-i386-as-3-fastrack...

Fetching rpm headers...
########################################

Name                                    Version        Rel
----------------------------------------------------------
kernel-smp-unsupported                  2.4.21         40.EL             i686
procps                                  2.0.17         13.10             i386
quagga                                  0.96.2         11.3E             i386
sendmail-doc                            8.12.11        4.RHEL3.6         i386


Testing package set / solving RPM inter-dependencies...
########################################
kernel-smp-unsupported-2.4. ########################## Done.
procps-2.0.17-13.10.i386.rp ########################## Done.
quagga-0.96.2-11.3E.i386.rp ########################## Done.
sendmail-doc-8.12.11-4.RHEL ########################## Done.
Preparing              ########################################### [100%]

Installing...
   1:procps                 ########################################### [100%]
   2:kernel-smp-unsupported ########################################### [100%]
   3:quagga                 ########################################### [100%]
   4:sendmail-doc           ########################################### [100%]
[root@dhcp100 ps-test-truncates]# ./run.sh
cmdline size (org=1995, new=     18) .... FAILED
===output===
[ps_truncates.sh]
============
[root@dhcp100 ps-test-truncates]# rpm -q procps
procps-2.0.17-13.10


-- Additional comment from bnocera on 2006-07-10 05:54 EST --
Keiichi is right. You need to run the test in /tmp/ps-test-truncates
I could reproduce it without any problems. I guess the testcase needs to be
updated, and made a bit more solid.

Comment 1 RHEL Program Management 2006-08-18 15:13:34 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.

Comment 2 Jay Turner 2006-08-21 19:19:49 UTC
QE ack for 4.5.

Comment 3 Karel Zak 2007-01-08 21:39:02 UTC
*** Bug 190174 has been marked as a duplicate of this bug. ***

Comment 5 Karel Zak 2007-01-17 11:06:04 UTC
Fixed. Update to procps-3.2.3-8.5.

Comment 10 Red Hat Bugzilla 2007-05-01 17:40:42 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2007-0237.html