Apport crashes when writing to stderr: UnicodeEncodeError: 'ascii' codec can't encode character '\xc1' in position 130: ordinal not in range(128)

Bug #1368911 reported by Dennis Schridde
36
This bug affects 7 people
Affects Status Importance Assigned to Milestone
apport (Ubuntu)
Triaged
Medium
Unassigned

Bug Description

Apport is invoked by the kernel via /proc/sys/kernel/core_pattern and crashes when writing some message to stderr:

ERROR: ERROR: apport (pid 23175) Fri Sep 12 22:51:58 2014: Unhandled exception:
Traceback (most recent call last):
  File "/usr/share/apport/apport", line 367, in <module>
    (info['ExecutablePath'], info['ProcCmdline']))
  File "/usr/share/apport/apport", line 99, in error_log
    apport.error('apport (pid %s) %s: %s', os.getpid(), time.asctime(), msg)
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 44, in error
    sys.stderr.write(msg % args)
UnicodeEncodeError: 'ascii' codec can't encode character '\xc1' in position 130: ordinal not in range(128)
ERROR: apport (pid 23175) Fri Sep 12 22:51:58 2014: pid: 23175, uid: 1000, gid: 1000, euid: 0, egid: 0
ERROR: apport (pid 23175) Fri Sep 12 22:51:58 2014: environment: environ({})

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: apport 2.14.1-0ubuntu3.4
ProcVersionSignature: Ubuntu 3.13.0-35.62-generic 3.13.11.6
Uname: Linux 3.13.0-35-generic x86_64
NonfreeKernelModules: wl
ApportVersion: 2.14.1-0ubuntu3.4
Architecture: amd64
CurrentDesktop: KDE
Date: Fri Sep 12 22:57:13 2014
InstallationDate: Installed on 2014-05-20 (115 days ago)
InstallationMedia: Kubuntu 14.04 LTS "Trusty Tahr" - Release amd64 (20140416.1)
PackageArchitecture: all
SourcePackage: apport
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Dennis Schridde (devurandom) wrote :
Revision history for this message
Dennis Schridde (devurandom) wrote :

Quick fix:
--- /usr/share/apport/apport.orig 2014-09-12 23:11:15.067594994 +0400
+++ /usr/share/apport/apport 2014-09-12 23:10:12.631595210 +0400
@@ -96,7 +96,7 @@
 def error_log(msg):
     '''Output something to the error log.'''

- apport.error('apport (pid %s) %s: %s', os.getpid(), time.asctime(), msg)
+ apport.error('apport (pid %s) %s: %s', os.getpid(), time.asctime(), msg.encode("utf-8"))

 def _log_signal_handler(sgn, frame):

But a better place to fix this would probably be apport.error().

Revision history for this message
schmod (schmod) wrote :

Similar issue with apport-kde:

  File "/usr/share/apport/apport-kde", line 530, in <module>
    sys.exit(UserInterface.run_argv())
  File "/usr/lib/python2.7/dist-packages/apport/ui.py", line 653, in run_argv
    return self.run_update_report()
  File "/usr/lib/python2.7/dist-packages/apport/ui.py", line 569, in run_update_report
    response = self.ui_present_report_details(allowed_to_report)
  File "/usr/share/apport/apport-kde", line 367, in ui_present_report_details
    desktop_info)
  File "/usr/share/apport/apport-kde", line 184, in __init__
    self.ui.ui_update_view(self)
  File "/usr/share/apport/apport-kde", line 358, in ui_update_view
    QTreeWidgetItem(keyitem, [str(line)])

Possible fix:

--- /usr/share/apport/apport-kde.orig 2015-11-03 15:03:25.923427902 -0500
+++ /usr/share/apport/apport-kde 2015-11-03 15:00:07.039222098 -0500
@@ -355,7 +355,7 @@
                not self.report._is_binary(self.report[key]):
                 lines = self.report[key].splitlines()
                 for line in lines:
- QTreeWidgetItem(keyitem, [str(line)])
+ QTreeWidgetItem(keyitem, [str(line.encode("UTF-8"))])
                 if len(lines) < 4:
                     keyitem.setExpanded(True)
             else:

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
penalvch (penalvch)
tags: added: xenial
Changed in apport (Ubuntu):
importance: Undecided → Medium
status: Confirmed → Triaged
Revision history for this message
Peridot (peridot) wrote :

This bug is still there on bionic dailies and the patch still works.

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.