Fails to process reports: UnicodeDecodeError in is_closing_session with non-ascii env

Bug #1281084 reported by Daniel Hahler
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
apport (Ubuntu)
Expired
High
Unassigned

Bug Description

From apport.log:

ERROR: apport (pid 11229) Mon Feb 17 13:26:22 2014: called for pid 11135, signal 11, core limit 18446744073709551615
ERROR: apport (pid 11229) Mon Feb 17 13:26:22 2014: ignoring implausibly big core limit, treating as unlimited
ERROR: apport (pid 11229) Mon Feb 17 13:26:22 2014: script: /usr/bin/pydoc2.7, interpreted by /usr/bin/python2.7 (command line "/usr/bin/python2.7 /usr/bin/pydoc -k .")
ERROR: apport (pid 11229) Mon Feb 17 13:26:22 2014: Unhandled exception:
Traceback (most recent call last):
  File "/usr/share/apport/apport", line 373, in <module>
    if is_closing_session(pid, pidstat.st_uid):
  File "/usr/share/apport/apport", line 214, in is_closing_session
    env = e.read().split('\0')
  File "/usr/lib/python3.3/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 9786: ordinal not in range(128)
ERROR: apport (pid 11229) Mon Feb 17 13:26:22 2014: pid: 11229, uid: 1000, gid: 1000, euid: 0, egid: 0
ERROR: apport (pid 11229) Mon Feb 17 13:26:22 2014: environment: environ({})

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:27:00 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 :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in apport (Ubuntu):
status: New → Confirmed
Revision history for this message
Václav Šmilauer (eudoxos) wrote :

Just adding more evidence:

ERROR: apport (pid 23189) Fri Aug 29 21:15:48 2014: called for pid 23182, signal 11, core limit 18446744073709551615
ERROR: apport (pid 23189) Fri Aug 29 21:15:48 2014: ignoring implausibly big core limit, treating as unlimited
ERROR: apport (pid 23189) Fri Aug 29 21:15:48 2014: executable: /usr/bin/gmsh (command line "gmsh")
ERROR: apport (pid 23189) Fri Aug 29 21:15:48 2014: Unhandled exception:
Traceback (most recent call last):
  File "/usr/share/apport/apport", line 391, in <module>
    if is_closing_session(pid, pidstat.st_uid):
  File "/usr/share/apport/apport", line 213, in is_closing_session
    env = e.read().split('\0')
  File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 65: ordinal not in range(128)
ERROR: apport (pid 23189) Fri Aug 29 21:15:48 2014: pid: 23189, uid: 1000, gid: 1000, euid: 0, egid: 0
ERROR: apport (pid 23189) Fri Aug 29 21:15:48 2014: environment: environ({})

Revision history for this message
Václav Šmilauer (eudoxos) wrote :

Just looking at the approt source, in is_closing_session, the error is here:

with open('/proc/%s/environ' % pid) as e:
        env = e.read().split('\0')

This is normally not a problem with python3, but apport runs for some reason with the ascii encoding, which will fail when reading utf-8 encoded environment variable (in my case, it is "DEBFULLNAME=Václav Šmilauer"). So the fix is perhaps

with open('/proc/%s/environ' % pid, encoding='utf-8') as e:
        env = e.read().split('\0')

(that's what I did locally) or open the file with 'rb' and work on bytes object rather than str.

Revision history for this message
Daniel Hahler (blueyed) wrote :

I can confirm that the patch (adding ", encoding='utf-8'") from Václav fixes this issue.

Changed in apport (Ubuntu):
status: Confirmed → Triaged
importance: Undecided → High
tags: added: patch
summary: - UnicodeDecodeError in is_closing_session
+ Fails to process reports: UnicodeDecodeError in is_closing_session with
+ non-ascii env
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: Triaged → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for apport (Ubuntu) because there has been no activity for 60 days.]

Changed in apport (Ubuntu):
status: Incomplete → Expired
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.