Workaround for modified sys.argv is incomplete

Bug #204940 reported by Stefan Fleiter
10
Affects Status Importance Assigned to Milestone
apport (Ubuntu)
Fix Released
Undecided
Martin Pitt

Bug Description

Binary package hint: apport

apport has some workaround for manipulated sys.argv in apport_excepthook.
This workaround is incomplete as can be seen in the following stacktrace generated by the incompatible hal 0.5.11~rc2-1ubuntu1 release.
The stacktrace is attached at the end.

I would recommend splitting the access to sys.argv and saving the
programs name in a row of its own and catching any Exception caused
by this single line.
The Exceptions of the os module should not be catched at all.

Traceback (most recent call last):
  File "/usr/share/python-support/kde-guidance-powermanager/guidance-power-manager.py", line 1120, in <module>
    mainWindow = PowermanagerApp(None, "main window")
  File "/usr/share/python-support/kde-guidance-powermanager/guidance-power-manager.py", line 1057, in __init__
    self.pmwidget = PowerManager(self,name)
  File "/usr/share/python-support/kde-guidance-powermanager/guidance-power-manager.py", line 96, in __init__
    self.powermanager = PowerManage()
  File "/usr/share/python-support/kde-guidance-powermanager/powermanage.py", line 107, in __init__
    self._checkSuspend()
  File "/usr/share/python-support/kde-guidance-powermanager/powermanage.py", line 253, in _checkSuspend
    self.canSuspend = properties["power_management.can_suspend_to_ram"]
KeyError: 'power_management.can_suspend_to_ram'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/apport_python_hook.py", line 42, in apport_excepthook
    binary = os.path.realpath(os.path.join(os.getcwdu(), sys.argv[0]))
IndexError: list index out of range

Original exception was:
Traceback (most recent call last):
  File "/usr/share/python-support/kde-guidance-powermanager/guidance-power-manager.py", line 1120, in <module>
    mainWindow = PowermanagerApp(None, "main window")
  File "/usr/share/python-support/kde-guidance-powermanager/guidance-power-manager.py", line 1057, in __init__
    self.pmwidget = PowerManager(self,name)
  File "/usr/share/python-support/kde-guidance-powermanager/guidance-power-manager.py", line 96, in __init__
    self.powermanager = PowerManage()
  File "/usr/share/python-support/kde-guidance-powermanager/powermanage.py", line 107, in __init__
    self._checkSuspend()
  File "/usr/share/python-support/kde-guidance-powermanager/powermanage.py", line 253, in _checkSuspend
    self.canSuspend = properties["power_management.can_suspend_to_ram"]
KeyError: 'power_management.can_suspend_to_ram'

Revision history for this message
Martin Pitt (pitti) wrote :

Thanks, fixed in bzr head.

Changed in apport:
assignee: nobody → pitti
status: New → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package apport - 0.106

---------------
apport (0.106) hardy; urgency=low

  [ Martin Pitt ]
  * apport/crashdb_impl/launchpad.py: Fix spelling mistake in p-lp-bugs API
    (now corrected there).
  * apport_python_hook.py: Catch IndexError for invalid sys.argv[0], too.
    (LP: #204940)
  * apport/ui.py: Add test_run_report_bug_unpackaged_pid() test case which
    reports a bug against a pid which belongs to an unpackaged program. This
    reproduces LP #203764.
  * apport/report.py: Drop add_hooks_info() assertion on nonexisting Package
    field, return silently instead. This conforms to the behaviour of the
    other add_*_info() functions and avoids nasty error handling.
  * apport/ui.py: Generate proper error message when calling with -f -p PID
    and PID belongs to an unpackaged program. (LP: #203764).

  [ Sebastien Bacher ]
  * po/Makevars: add the --language=python xgettext option so the translations
    template is correctly updated on build since cdbs is using intltool-update
    directly and not the corresponding makefile target

 -- Martin Pitt <email address hidden> Tue, 01 Apr 2008 16:02:46 +0200

Changed in apport:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.