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 1669294 - RuntimeError is raised if a process vanishes while pidstats.reload_threads() executes
Summary: RuntimeError is raised if a process vanishes while pidstats.reload_threads() ...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: python-linux-procfs
Version: 8.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: rc
: 8.0
Assignee: John Kacur
QA Contact: Qiao Zhao
URL:
Whiteboard:
: 1666680 1676962 (view as bug list)
Depends On:
Blocks: 1640832 1649545 1665995
TreeView+ depends on / blocked
 
Reported: 2019-01-24 21:09 UTC by Ondřej Lysoněk
Modified: 2019-06-14 01:49 UTC (History)
6 users (show)

Fixed In Version: python3-linux-procfs-0.6-6.el8
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-06-14 01:49:33 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Fix refreshing cache (1.22 KB, patch)
2019-01-25 16:47 UTC, John Kacur
no flags Details | Diff

Description Ondřej Lysoněk 2019-01-24 21:09:53 UTC
Description of problem:
If a process disappears while iterating the loop in pidstats.reload_threads(), we get a RuntimeError as shown below. This is because we cannot remove an entry from a dictionary while iterating the dictionary.

This problem is the cause of the following Tuned error reported in bug#1666562:
2019-01-16 03:22:34,859 ERROR    tuned.units.manager: BUG: Unhandled exception in start_tuning: dictionary changed size during iteration

Version-Release number of selected component (if applicable):
python3-linux-procfs-0.6-5.el8.noarch

How reproducible:
always

Steps to Reproduce:
1. Add the following line to the beginning of pidstats.reload_threads() in /usr/lib/python3.6/site-packages/procfs/procfs.py:
import pdb; pdb.set_trace()
2. Start some process
3. Start the python interpreter and proceed as follows:
# python3
Python 3.6.8 (default, Jan 11 2019, 02:17:16) 
[GCC 8.2.1 20180905 (Red Hat 8.2.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import procfs
>>> ps = procfs.pidstats()
>>> ps.reload_threads()
> /usr/lib/python3.6/site-packages/procfs/procfs.py(463)reload_threads()
-> for pid in self.processes.keys():
(Pdb) next
> /usr/lib/python3.6/site-packages/procfs/procfs.py(464)reload_threads()
-> try:
(Pdb) 

At this point, terminate the process started in step 2. Return to the
python interpreter:

(Pdb) continue
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/site-packages/procfs/procfs.py", line 465, in reload_threads
    self.processes[pid].load_threads()
RuntimeError: dictionary changed size during iteration


Actual results:
RuntimeError is raised

Expected results:
reload_threads() finishes without errors

Additional info:
A fix for the problem has been sent upstream:
https://lists.fedorahosted.org/archives/list/tuna-devel@lists.fedorahosted.org/thread/PK354CZETOV23PJPMJ7CZCK7SOOV2JX6/

Comment 1 Ondřej Lysoněk 2019-01-24 21:12:12 UTC
*** Bug 1666680 has been marked as a duplicate of this bug. ***

Comment 2 Luiz Capitulino 2019-01-25 13:36:59 UTC
I'm raising severity because when this issue triggers the realtime tuned profiles fail to apply.

Comment 3 John Kacur 2019-01-25 16:47:27 UTC
Created attachment 1523545 [details]
Fix refreshing cache

We should consider applying this one too

Comment 10 Luiz Capitulino 2019-01-30 17:42:18 UTC
FWIW, I quickly verified the reproducer found when debugging bug 1665995
and it works for me too.

Thanks everyone for fixing this one so quickly!

Comment 11 Luiz Capitulino 2019-02-13 14:59:46 UTC
Can we set the "Fixed In Version" field so that we know when this was fixed? Thanks.

Comment 12 Beth Uptagrafft 2019-02-13 20:32:51 UTC
(In reply to Luiz Capitulino from comment #11)
> Can we set the "Fixed In Version" field so that we know when this was fixed?
> Thanks.

Done - python3-linux-procfs-0.6-6.el8

Comment 13 Ondřej Lysoněk 2019-02-19 14:44:55 UTC
*** Bug 1676962 has been marked as a duplicate of this bug. ***


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