Bug 837621 - sa -u cause Segmentation fault
sa -u cause Segmentation fault
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: psacct (Show other bugs)
Unspecified Unspecified
high Severity high
: rc
: ---
Assigned To: Jaromír Cápík
Branislav Náter
: ZStream
Depends On:
Blocks: 838998
  Show dependency treegraph
Reported: 2012-07-04 08:09 EDT by Branislav Náter
Modified: 2013-11-14 05:41 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2013-11-14 05:41:11 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Branislav Náter 2012-07-04 08:09:56 EDT
Description of problem:
Running sa -u (print also user id) command cause Segmentation fault on i386 and s390x archs and produce incorect output on x86_64.

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

How reproducible:

Steps to Reproduce:
1. run "sa -u"
Actual results on different archs:
ppc64:  root       0.00 cpu       62k mem accton
x86_64: 13179672   0.00 cpu      979k mem accton
i386:   Segmentation fault
s390x:  Segmentation fault

Expected results:
root       0.00 cpu       62k mem accton

Additional info:
Output seems to be correct only on ppc64 architecture.

Traceback from i386:
(gdb) t a a bt

Thread 1 (process 14151):
#0  0x0804a3f4 in parse_acct_entries () at sa.c:1254
#1  0x0804abea in main (argc=2, argv=0xbffff364) at sa.c:585

Traceback from s390x:
(gdb) t a a bt

Thread 1 (process 8385):
#0  0x0000000080002b96 in parse_acct_entries () at sa.c:1254
#1  0x0000000080003312 in main (argc=<value optimized out>, argv=<value optimized out>) at sa.c:585
Comment 1 Jaromír Cápík 2012-07-10 10:00:21 EDT
rec->ac_uid is invalid for some reason ... needs a deeper analysis.
Comment 2 Jaromír Cápík 2012-07-10 10:19:56 EDT
Some parts of the code are really very strange ...


# define ACCT_BYTEORDER 0x80        /* Accounting file is big endian.  */
# define ACCT_BYTEORDER 0x00        /* Accounting file is little endian.  */


if ((version % ACCT_BYTEORDER) != 3) {


Anything modulo 0 must throw SIGFPE ... 

Fortunately the structure seems to be BIG ENDIAN even on LITTLE_ENDIAN architectures ... this has been redesigned in the new upstream version.
Comment 3 Jaromír Cápík 2012-07-10 10:30:49 EDT
It seems I've found the issue. The ac_uid field needs to be read from the rec_v3 variable in case of acct_v3 structures. The acct structure version detection is a bit nonsense, but it doesn't cause the trouble. It was a human factor ... a cut'n'paste issue. Gonna test that on other architectures.

Note You need to log in before you can comment on or make changes to this bug.