Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1857580

Summary: pcp-atopsar crashes with SIGSEGV in totalsyst [rhel-7.9.z]
Product: Red Hat Enterprise Linux 7 Reporter: Divya <dbasant>
Component: pcpAssignee: Nathan Scott <nathans>
Status: CLOSED ERRATA QA Contact: Jan Kurik <jkurik>
Severity: low Docs Contact:
Priority: low    
Version: 7.8CC: agerstmayr, alanm, jkurik, jreznik, mgoodwin, nathans, patrickm, vikpatil, yuokada
Target Milestone: rcKeywords: Bugfix, Patch, Triaged, ZStream
Target Release: 7.9   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pcp-4.3.2-13.el7_9 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-12-15 11:18:17 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Allocating the memory for percpu pointer if it is NULL dbasant: review?

Description Divya 2020-07-16 07:59:49 UTC
Created attachment 1701345 [details]
Allocating the memory for percpu pointer if it is NULL

Created attachment 1701345 [details]
Allocating the memory for percpu pointer if it is NULL

Description of problem:
Core was generated by `/usr/libexec/pcp/bin/pcp-atopsar -R 6 -r y'.
Program terminated with signal 11, Segmentation fault.
#0  0x000000000040944b in totalsyst (category=99 'c', new=0x24aa960, tot=0x638ac0 <totsyst.10504>) at deviate.c:1398
1398				tot->cpu.cpu[0] = tot->cpu.all;
(gdb) bt
#0  0x000000000040944b in totalsyst (category=99 'c', new=0x24aa960, tot=0x638ac0 <totsyst.10504>) at deviate.c:1398
#1  0x00000000004077fb in reportraw (curtime=<optimized out>, numsecs=<optimized out>, devtstat=<optimized out>, sstat=<optimized out>, nexit=<optimized out>, noverflow=<optimized out>, flags=<optimized out>)
    at atopsar.c:753
#2  0x000000000040396f in engine () at atop.c:684
#3  0x0000000000408244 in atopsar (argc=<optimized out>, argv=<optimized out>) at atopsar.c:338
#4  0x0000000000403138 in main (argc=5, argv=0x7ffe4041d8c8) at atop.c:312
(gdb) list
1393			tot->cpu.all.steal += new->cpu.all.steal;
1394			tot->cpu.all.guest += new->cpu.all.guest;
1395	
1396			if (new->cpu.nrcpu == 1)
1397			{
1398				tot->cpu.cpu[0] = tot->cpu.all;
1399			}
1400			else
1401			{
1402				for (i=0; i < new->cpu.nrcpu; i++)
(gdb) p tot->cpu
$3 = {nrcpu = 1, devint = 7896, csw = 24381, nprocs = 2539, lavg1 = 0, lavg5 = 0, lavg15 = 0, all = {cpunr = 0, stime = 2275, utime = 2041, ntime = 0, itime = 5652, wtime = 0, Itime = 0, Stime = 4, steal = 0, 
    guest = 0, freqcnt = {maxfreq = 0, cnt = 0, ticks = 0}, instr = 0, cycle = 0}, cpu = 0x0}
(gdb) p tot->cpu.all
$4 = {cpunr = 0, stime = 2275, utime = 2041, ntime = 0, itime = 5652, wtime = 0, Itime = 0, Stime = 4, steal = 0, guest = 0, freqcnt = {maxfreq = 0, cnt = 0, ticks = 0}, instr = 0, cycle = 0}
(gdb) p tot->cpu.cpu
$5 = (struct percpu *) 0x0

Version-Release number of selected component (if applicable):
pcp-system-tools-4.3.2-7.el7_8

How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:
pcp-atopsar crashes with SISEGV

Expected results:
pcp-atopsar should fetch the results without crashing

Additional info:
I articulated a patch to fix the issue and customer has confirmed that it fixes the issue for him and and pcp-atopsar does not crash with fix attached here(atopsar-cpu.patch)

Comment 1 Nathan Scott 2020-07-17 06:54:07 UTC
Hi Divya!

Thanks for working on this - your patch looks good.  Reviewing the code, there's a couple more aspects:

- the code now handles the CPU allocations case, but there's other cases too (interfaces, disks) later on in the code - we'll need to add allocations for those too I think;
- there's a memory leak: we're calling this function in a loop, and sometimes will zero the pointers without freeing the memory (see the memset calls in atopsar.c).

I can look into these early next week, and write a regression test - I'm out of time for today though.

Can you give some indication as to customer expectations on a fix here, Divya?  At the moment we're trying to focus our development efforts on RHEL-8.  Thanks again!

Comment 2 Nathan Scott 2020-07-21 01:47:26 UTC
Fix is updated, regression tested and upstream now.  Divya, its too late for RHEL 7.9 and there will be no RHEL 7.10 - we'll need to know if the customer needs a zstream update or whether fixing this in RHEL-8 will suffice.

commit f99c6cbdf8b1fbccd0e39102249dca2c5aecbe55
Author: Nathan Scott <nathans>
Date:   Tue Jul 21 11:42:28 2020 +1000

    pcp-atopsar: fix memory allocation problem with some options
    
    Make sure we have sufficient memory for target CPU/disk/net copies.
    Thanks to Divya Basant for early work on this and an initial fix. A
    new regression test - qa/1820 - is added to exercise the change.
    
    Resolves Red Hat BZ #1857580.

Comment 21 errata-xmlrpc 2020-12-15 11:18:17 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (pcp bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:5440