Bug 2172433 - dnf happen AttributeError and RuntimeError when io busy and press ctrl c
Summary: dnf happen AttributeError and RuntimeError when io busy and press ctrl c
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: 37
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: rpm-software-management
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-02-22 11:33 UTC by chenhaixing
Modified: 2024-01-12 22:50 UTC (History)
9 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2024-01-12 22:50:26 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description chenhaixing 2023-02-22 11:33:40 UTC
Description of problem:


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


How reproducible:


Steps to Reproduce:
1. I/O busy causes system is sluggishness
2. dnf install -y package
3. ctrl+ c

Actual results:
Sometimes:
Traceback (most recent call last):
  File "/usr/bin/dnf", line 58, in <module>
    main.user_main(sys.argv[1:], exit_code=True)
  File "/usr/lib/python3.9/site-packages/dnf/cli/main.py", line 201, in user_main
    errcode = main(args)
  File "/usr/lib/python3.9/site-packages/dnf/cli/main.py", line 66, in main
    with dnf.cli.cli.BaseCli(conf_class()) as base:
  File "/usr/lib/python3.9/site-packages/dnf/conf/config.py", line 228, in __init__
    config = libdnf.conf.ConfigMain()
  File "/usr/lib64/python3.9/site-packages/libdnf/conf.py", line 1122, in __init__
    _conf.ConfigMain_swiginit(self, _conf.new_ConfigMain())
RuntimeError: SWIG director method error. Error detected when calling 'Logger.write'
Exception ignored in: <function MainConf.__del__ at 0x7f2b9f882430>
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/dnf/conf/config.py", line 261, in __del__
    for file_name in self.tempfiles:
  File "/usr/lib/python3.9/site-packages/dnf/conf/config.py", line 66, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'".format(self.__class__, name))
AttributeError: '<class 'dnf.conf.config.MainConf'>' object has no attribute 'tempfiles'


Expected results:
no AttributeError

Additional info:
I think that the reason of AttributeError is dnf.conf.config.MainConf is not initialized yet cause by 'ctrl + c' when the system is busy.

Possible Solutions:Add attribute judgment before self use 'tempfiles' in dnf/conf/config.py
PR:https://github.com/rpm-software-management/dnf/pull/1899

Comment 1 chenhaixing 2023-02-27 11:05:00 UTC
PR is merged:https://github.com/rpm-software-management/dnf/pull/1899

Comment 2 chenhaixing 2023-03-03 10:17:13 UTC
AttributeError has been resolved.
Unfortunately, RuntimeError still exists.

Comment 3 chenhaixing 2023-03-09 06:06:52 UTC
Do you think 'RuntimeError' is a problem. 
@mblaha

Comment 4 Marek Blaha 2023-03-09 10:55:53 UTC
The problem here is here:

File "/usr/lib/python3.9/site-packages/dnf/cli/main.py", line 66, in main
    with dnf.cli.cli.BaseCli(conf_class()) as base:

When instantiating the conf (conf_class()) the Runtime exception was raised. But this type of exception is not caught in the try / except block here, so it propagates all the way up and eventually the user sees the traceback.

Python has this quirky behavior that `__del__()` is being called on the object even though the call of `__init__()` of the same object had failed (thus object is not correctly constructed). This might very easily result in the AttributeError you were originally dealing with.

Comment 5 chenhaixing 2023-03-09 11:21:40 UTC
Thank you for your reply. I agree with you.
Not only dnf, but also other python packages have traceback(e.g., iotop, firewalld) 
Different Python packages have different tracebacks.

Comment 6 Aoife Moloney 2023-11-23 01:18:42 UTC
This message is a reminder that Fedora Linux 37 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 37 on 2023-12-05.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '37'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version. Note that the version field may be hidden.
Click the "Show advanced fields" button if you do not see it.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 37 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 7 Aoife Moloney 2024-01-12 22:50:26 UTC
Fedora Linux 37 entered end-of-life (EOL) status on 2023-12-05.

Fedora Linux 37 is no longer maintained, which means that it
will not receive any further security or bug fix updates. As a result we
are closing this bug.

If you can reproduce this bug against a currently maintained version of Fedora Linux
please feel free to reopen this bug against that version. Note that the version
field may be hidden. Click the "Show advanced fields" button if you do not see
the version field.

If you are unable to reopen this bug, please file a new report against an
active release.

Thank you for reporting this bug and we are sorry it could not be fixed.


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