time reports incorrect max rss

Bug #742248 reported by Dejan Jovanović
34
This bug affects 6 people
Affects Status Importance Assigned to Milestone
time (Debian)
Fix Released
Unknown
time (Fedora)
Fix Released
Undecided
time (Ubuntu)
Incomplete
Undecided
Unassigned

Bug Description

Binary package hint: time

rusage reports max rss and other memory information in KB and time assumes it is in number of pages, so it multiplies it with 4, resulting in inflated max rss

ProblemType: Bug
DistroRelease: Ubuntu 10.10
Package: time 1.7-23ubuntu1
ProcVersionSignature: Ubuntu 2.6.35-28.49-generic 2.6.35.11
Uname: Linux 2.6.35-28-generic i686
NonfreeKernelModules: wl
Architecture: i386
Date: Fri Mar 25 00:38:03 2011
InstallationMedia: Ubuntu-Netbook 10.04 "Lucid Lynx" - Release i386 (20100429.4)
ProcEnviron:
 LANGUAGE=en_US:en
 PATH=(custom, user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: time

Revision history for this message
Dejan Jovanović (dddejan) wrote :
Revision history for this message
In , Michael (michael-redhat-bugs) wrote :

Description of problem:

GNU time can print out the maximum RSS usage of its subprocess. The ru_maxrss value returned by the wait4 syscall is in units of kilobytes, but GNU time incorrectly treats this as a number of pages, multiplying the value by 4 before displaying it.

Version-Release number of selected component (if applicable):
time-1.7-37.fc12.i686

How reproducible: Always

Steps to Reproduce:
1. /usr/bin/time -f %M perl -e '"x" x 400 x 1024 x 1024'

Actual results: A bit over 1600000, indicating maximum RSS usage of 1.6 GB. This is not even possible on my system as it only has 1 GB of physical RAM.

Expected results: Approximately 400000, since Perl should only be allocating around 400 MB.

Additional info:

Applying strace to the above command, it is clear that time is multiplying the ru_maxrss value returned by wait4:

$ strace -ve wait4 /usr/bin/time -f %M perl -e '"x" x 400 x 1024 x 1024'
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, {ru_utime={0, 146977}, ru_stime={0, 676897}, ru_maxrss=411356, ru_ixrss=0, ru_idrss=0, ru_isrss=0, ru_minflt=102901, ru_majflt=1, ru_nswap=0, ru_inblock=176, ru_oublock=0, ru_msgsnd=0, ru_msgrcv=0, ru_nsignals=0, ru_nvcsw=1, ru_nivcsw=40}) = 7459
--- {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=7459, si_status=0, si_utime=14, si_stime=68} (Child exited) ---
1645424

According to the getrusage(2) manpage:

  ru_maxrss (since Linux 2.6.32)
     This is the maximum resident set size used (in kilobytes). [...]

I've attached a simple patch that simply skips the "pages to kilobytes" conversion for this field.

Revision history for this message
In , Michael (michael-redhat-bugs) wrote :

Created attachment 497533
Do not incorrectly convert ru_maxrss

Revision history for this message
smlx (sml) wrote :

There's a patch on the fedora bugzilla for this issue:
https://bugzilla.redhat.com/show_bug.cgi?id=702826

Changed in time (Ubuntu):
status: New → Confirmed
Revision history for this message
In , Petr (petr-redhat-bugs) wrote :

All Fedoras affected (time-1.7).

Revision history for this message
In , Petr (petr-redhat-bugs) wrote :

Thank you for the report, fixed time version will be pushed into Fedoras soon.

Revision history for this message
In , Petr (petr-redhat-bugs) wrote :

Fixed in time-1.7-39.fc16 for F16.

Revision history for this message
In , Fedora (fedora-redhat-bugs) wrote :

time-1.7-39.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/time-1.7-39.fc15

Revision history for this message
In , Fedora (fedora-redhat-bugs) wrote :

time-1.7-38.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/time-1.7-38.fc14

Revision history for this message
In , Fedora (fedora-redhat-bugs) wrote :

time-1.7-38.fc13 has been submitted as an update for Fedora 13.
https://admin.fedoraproject.org/updates/time-1.7-38.fc13

Revision history for this message
In , Fedora (fedora-redhat-bugs) wrote :

Package time-1.7-38.fc14:
* should fix your issue,
* was pushed to the Fedora 14 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing time-1.7-38.fc14'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/time-1.7-38.fc14
then log in and leave karma (feedback).

Revision history for this message
In , Fedora (fedora-redhat-bugs) wrote :

time-1.7-39.fc15 has been pushed to the Fedora 15 stable repository. If problems still persist, please make note of it in this bug report.

Revision history for this message
In , Fedora (fedora-redhat-bugs) wrote :

time-1.7-38.fc14 has been pushed to the Fedora 14 stable repository. If problems still persist, please make note of it in this bug report.

Revision history for this message
In , Fedora (fedora-redhat-bugs) wrote :

time-1.7-38.fc13 has been pushed to the Fedora 13 stable repository. If problems still persist, please make note of it in this bug report.

Revision history for this message
Peter Bašista (pbasista) wrote :

Attaching a patch to the oneiric version of package time.

Changed in time (Ubuntu):
status: Confirmed → In Progress
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "time.patch" of this bug report has been identified as being a patch. The ubuntu-reviewers team has been subscribed to the bug report so that they can review the patch. In the event that this is in fact not a patch you can resolve this situation by removing the tag 'patch' from the bug report and editing the attachment so that it is not flagged as a patch. Additionally, if you are member of the ubuntu-sponsors please also unsubscribe the team from this bug report.

[This is an automated message performed by a Launchpad user owned by Brian Murray. Please contact him regarding any issues with the action taken in this bug report.]

tags: added: patch
Revision history for this message
Peter Bašista (pbasista) wrote :

Hello?

Is anybody watching this?

I can not commit the attached patch myself, so ...
Can I ask someone who can, ... would you be that kind and do that, please?
Thank you!

Changed in time (Ubuntu):
status: In Progress → Incomplete
Revision history for this message
Dejan Jovanović (dddejan) wrote :

What is the way ahead with this. I submitted the bug a year ago, and it's lame that nobody except Peter cares about it. Is there something I can do to speed it up?

Changed in time (Debian):
status: Unknown → New
Changed in time (Debian):
status: New → Fix Released
Changed in time (Fedora):
importance: Unknown → Undecided
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.