Bug 798692

Summary: [abrt] wicd-common-1.7.0-10.fc16: wicd-daemon.py:1807:main:UnboundLocalError: local variable 'child_pid' referenced before assignment
Product: [Fedora] Fedora Reporter: a.thiaville
Component: wicdAssignee: David Cantrell <dcantrell>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 16CC: dcantrell
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard: abrt_hash:81f500827c80c6afaf5043629eacc3fd1fff72bb
Fixed In Version: wicd-1.7.0-12.fc16 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-04-11 16:53:54 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description a.thiaville 2012-02-29 15:26:51 UTC
libreport version: 2.0.8
abrt_version:   2.0.7
cmdline:        python /usr/share/wicd/daemon/wicd-daemon.py --no-daemon --no-poll
executable:     /usr/share/wicd/daemon/wicd-daemon.py
kernel:         3.2.3-2.fc16.x86_64
reason:         wicd-daemon.py:1807:main:UnboundLocalError: local variable 'child_pid' referenced before assignment
time:           mar. 28 févr. 2012 14:29:48 CET
uid:            0
username:       root

backtrace:
:wicd-daemon.py:1807:main:UnboundLocalError: local variable 'child_pid' referenced before assignment
:
:Traceback (most recent call last):
:  File "/usr/share/wicd/daemon/wicd-daemon.py", line 1838, in <module>
:    main(sys.argv)
:  File "/usr/share/wicd/daemon/wicd-daemon.py", line 1807, in main
:    atexit.register(on_exit, child_pid)
:UnboundLocalError: local variable 'child_pid' referenced before assignment
:
:Local variables in innermost frame:
:a: ''
:daemon: <__main__.WicdDaemon at /org/wicd/daemon at 0x171e750>
:auto_connect: True
:no_poll: True
:bus: <dbus._dbus.SystemBus (system) at 0x17222f0>
:args: []
:logpath: '/var/log/wicd.log'
:redirect_stdout: True
:wicd_bus: <dbus.service.BusName org.wicd.daemon on <dbus._dbus.SystemBus (system) at 0x17222f0> at 0x1715f50>
:redirect_stderr: True
:do_daemonize: False
:backup_location: '/var/lib/wicd/resolv.conf.orig'
:kill: False
:o: '--no-poll'
:argv: ['/usr/share/wicd/daemon/wicd-daemon.py', '--no-daemon', '--no-poll']
:output: ManagedStdio('/var/log/wicd.log', 360000, 3)
:opts: [('--no-daemon', ''), ('--no-poll', '')]

comment:
:1) reproductible : always with the command line argument "--no-poll" (see the report's "Problem description") . The problem can
:                      immediatly correctly with this patch :
:
:2)preceived severity : very HiGH:
:        direct consequence of the problem: keep an "orphan" /var/run/wicd.pid file  when the daemon dies !!!! 
:3) patches proposed to correct the problem
:  - old code (extracts ):
:
:1803     if not no_poll:
:1804         child_pid = Popen([misc.find_path("python"), "-O",
:1805                           os.path.join(wpath.daemon, "monitor.py")],
:1806                           shell=False, close_fds=True).pid
:1807     atexit.register(on_exit, child_pid)
:   a) new code: (in the coding style of lines producing the bug /usr/share/wicd/daemon/wicd-daemon.py)
:1803     if not no_poll:
:1804         child_pid = Popen([misc.find_path("python"), "-O",
:1805                           os.path.join(wpath.daemon, "monitor.py")],
:1806                           shell=False, close_fds=True).pid
:1807     else:
:1808         child_pid = None
:1809     atexit.register(on_exit, child_pid)
:  b) my (preferred ) coding style (initalize variable before using it ... )
:1803     child_pid = None
:1804     if not no_poll: 
:1805         child_pid = Popen([misc.find_path("python"), "-O", 
:1806                           os.path.join(wpath.daemon, "monitor.py")],
:1807                           shell=False, close_fds=True).pid
:1808     atexit.register(on_exit, child_pid)
:1809     
: 
:My comments <=> proposals related to the problem: "harden" the code 
:        proposals  : 
:           a) maybe harden the 'on_exit' handler from catchable exceptions : As a "normal" unix/linux daemon, the wicd.pid file
:                must at least be deleted when the process dies.
:           b)  the code  /usr/share/wicd/daemon/wicd-daeme·lucon.py by itself doesn't support multi-instances and doesn't chek it
:              it's very easy to launch many instances.The second one,by example overwrites the pid of the first daemon ...
:              No protection (as locking, ...)  required by concurency processing exist in the code and will ineluctably raise many bugs more and   
:               difficult to investigate...
:             As a traditionnal non forking daemon, never launch a new instance or exit before any share resource can be corrupted
:           by the new one.
:             
:  P.S these comments are maybe severe, but they just apply to the problem reported. The package is well-written, thanks to
:      the authors of  "wicd-daemon".
:

Comment 1 Fedora Update System 2012-03-26 20:04:38 UTC
wicd-1.7.0-12.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/wicd-1.7.0-12.fc16

Comment 2 Fedora Update System 2012-03-31 02:58:50 UTC
Package wicd-1.7.0-12.fc16:
* should fix your issue,
* was pushed to the Fedora 16 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing wicd-1.7.0-12.fc16'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-4962/wicd-1.7.0-12.fc16
then log in and leave karma (feedback).

Comment 3 Fedora Update System 2012-04-11 16:53:54 UTC
wicd-1.7.0-12.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.