Crash in os.environ.clear() with empty environment key

Bug #1281086 reported by Daniel Hahler
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Python
New
Unknown
apport (Ubuntu)
Invalid
Undecided
Unassigned
python2.7 (Ubuntu)
Confirmed
Medium
Unassigned
python3.3 (Ubuntu)
Confirmed
Medium
Unassigned

Bug Description

% ubuntu-bug apport
Traceback (most recent call last):
  File "/usr/share/apport/apport-gtk", line 590, in <module>
    app.run_argv()
  File "/usr/lib/python3/dist-packages/apport/ui.py", line 654, in run_argv
    return self.run_report_bug()
  File "/usr/lib/python3/dist-packages/apport/ui.py", line 456, in run_report_bug
    self.collect_info(symptom_script)
  File "/usr/lib/python3/dist-packages/apport/ui.py", line 1031, in collect_info
    os.environ.clear()
  File "/usr/lib/python3.3/collections/abc.py", line 553, in clear
    self.popitem()
  File "/usr/lib/python3.3/collections/abc.py", line 546, in popitem
    del self[key]
  File "/usr/lib/python3.3/os.py", line 687, in __delitem__
    self.unsetenv(encodedkey)
OSError: [Errno 22] Invalid argument

Looking at the output of `os.environ`, there is a odd entry (key '').

os.environ.clear() fails both with python2.7 and python3:

In [1]: import os

In [2]: os.environ[''] = ''

In [3]: os.environ.clear()
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-3-bfe7fb2930ac> in <module>()
----> 1 os.environ.clear()

/usr/lib/python3.3/collections/abc.py in clear(self)
    551 try:
    552 while True:
--> 553 self.popitem()
    554 except KeyError:
    555 pass

/usr/lib/python3.3/collections/abc.py in popitem(self)
    544 raise KeyError
    545 value = self[key]
--> 546 del self[key]
    547 return key, value
    548

/usr/lib/python3.3/os.py in __delitem__(self, key)
    685 def __delitem__(self, key):
    686 encodedkey = self.encodekey(key)
--> 687 self.unsetenv(encodedkey)
    688 try:
    689 del self._data[encodedkey]

OSError: [Errno 22] Invalid argument

While this looks like a bug to be fixed in Python also, apport should handle it gracefully, and not crash/abort on it.

ProblemType: Bug
DistroRelease: Ubuntu 13.10
Package: apport 2.12.5-0ubuntu2.2
ProcVersionSignature: Ubuntu 3.11.0-15.25-generic 3.11.10
Uname: Linux 3.11.0-15-generic x86_64
ApportVersion: 2.12.5-0ubuntu2.2
Architecture: amd64
CrashReports:
 640:1000:114:120104180:2014-02-13 00:58:41.677010970 +0100:2014-02-13 00:57:20.989009053 +0100:/var/crash/_opt_firefox_firefox.1000.crash
 640:1000:114:63870076:2014-02-13 00:00:35.972928127 +0100:2014-02-12 23:59:49.260927017 +0100:/var/crash/_usr_lib_firefox_firefox.1000.crash
 640:1000:114:14175879:2014-02-09 10:23:03.104148831 +0100:2014-02-09 10:22:57.576148699 +0100:/var/crash/_usr_bin_nautilus.1000.crash
Date: Mon Feb 17 13:41:48 2014
InstallationDate: Installed on 2012-05-28 (629 days ago)
InstallationMedia: Ubuntu 12.04 LTS "Precise Pangolin" - Release amd64 (20120425)
MarkForUpload: True
PackageArchitecture: all
SourcePackage: apport
UpgradeStatus: Upgraded to saucy on 2013-10-08 (131 days ago)
modified.conffile..etc.default.apport: [modified]
mtime.conffile..etc.default.apport: 2014-02-13T00:58:07.609010

Revision history for this message
Daniel Hahler (blueyed) wrote :
description: updated
summary: - Apport might crash when clearing environment (via os.environ.clear()
- with empty environ key)
+ Crash in os.environ.clear() with empty environment key
Changed in python:
status: Unknown → New
Matthias Klose (doko)
Changed in python2.7 (Ubuntu):
importance: Undecided → Medium
status: New → Confirmed
Changed in python3.3 (Ubuntu):
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

This release of Ubuntu is no longer receiving maintenance updates. If this is still an issue on a maintained version of Ubuntu please let us know.

Changed in apport (Ubuntu):
status: New → Incomplete
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

This issue has sat incomplete for more than 60 days now. I'm going to close it as invalid. Please feel free re-open if this is still an issue for you. Thank you.

Changed in apport (Ubuntu):
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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