apport-collect crash when sending log file and using a non-English locale ("TypeError: 'unicode' does not have the buffer interface")

Bug #1030483 reported by Thomas
46
This bug affects 12 people
Affects Status Importance Assigned to Milestone
apport (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

In the process of updating #1030151 I was hit by a bug in apport-collect. When doing
apport-collect 1030151
in a root console the apport-collect would crash with following trace back :

Traceback (most recent call last):
  File "/usr/share/apport/apport-gtk", line 587, in <module>
    app.run_argv()
  File "/usr/lib/python2.7/dist-packages/apport/ui.py", line 634, in run_argv
    return self.run_update_report()
  File "/usr/lib/python2.7/dist-packages/apport/ui.py", line 554, in run_update_report
    attachment_comment='apport information')
  File "/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.py", line 356, in update
    report.write_mime(mime, skip_keys=skip_keys)
  File "/usr/lib/python2.7/dist-packages/problem_report.py", line 505, in write_mime
    attach_value = CompressedValue(v, k).gzipvalue
  File "/usr/lib/python2.7/dist-packages/problem_report.py", line 44, in __init__
    self.set_value(value)
  File "/usr/lib/python2.7/dist-packages/problem_report.py", line 50, in set_value
    gzip.GzipFile(self.name, mode='wb', fileobj=out).write(value)
  File "/usr/lib/python2.7/gzip.py", line 131, in __init__
    self._write_gzip_header()
  File "/usr/lib/python2.7/gzip.py", line 176, in _write_gzip_header
    self.fileobj.write(fname + '\000')
TypeError: 'unicode' does not have the buffer interface

Calling apport-collect with LC_ALL=C or LANG=C as suggest by Edward Donovan didn't solve the issue.

I used this workaround : in /usr/lib/python2.7/dist-packages/problem_report.py I replaced line 50 :
gzip.GzipFile(self.name, mode='wb', fileobj=out).write(value)
by :
gzip.GzipFile(self.name.encode('UTF-8'), mode='wb', fileobj=out).write(value.encode('UTF-8'))

It's a quick and dirty hack but maybe it will help the developpers to trully solve the issue.

Cheers !

ProblemType: Bug
DistroRelease: Ubuntu 12.10
Package: apport 2.4-0ubuntu6
ProcVersionSignature: Ubuntu 3.5.0-6.6-generic 3.5.0
Uname: Linux 3.5.0-6-generic x86_64
ApportLog:

ApportVersion: 2.4-0ubuntu6
Architecture: amd64
CrashReports:
 644:0:110:0:2012-07-29 12:14:17.260971307 +0200:2012-07-29 12:14:17.260971307 +0200:/var/crash/_sbin_plymouthd.0.upload
 600:105:110:0:2012-07-29 12:14:25.388971230 +0200:2012-07-29 12:14:25.388971230 +0200:/var/crash/_sbin_plymouthd.0.uploaded
 640:0:110:1232461:2012-07-29 12:08:44.732974000 +0200:2012-07-29 12:14:18.284971294 +0200:/var/crash/_sbin_plymouthd.0.crash
Date: Sun Jul 29 12:53:17 2012
InstallationMedia: Ubuntu 12.10 "Quantal Quetzal" - Alpha amd64 (20120627)
PackageArchitecture: all
ProcEnviron:
 TERM=xterm
 PATH=(custom, no user)
 LANG=fr_FR.UTF-8
 SHELL=/bin/bash
SourcePackage: apport
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Thomas (thcourbon) 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
Edward Donovan (edward.donovan) wrote :

It seems like apport has a number of internationalization problems. (After typing that, now I see why they write i18n!) Like,

* bug 492290
* bug 616767
* bug 768613
* bug 827090

Hopefully, after adapting the code, python 3 could be better at handling the unicode issues among these. Maybe a little project reviewing the code for these issues would be good. We might consider problems like bug 1016380, where string objects need to be made into byte objects, somewhat related.

I don't have much experience in this area, but it seems like a nice thing to improve, and I'll try to look into it if I get time.

After reading bug 492290, I had suggested setting locale variables to 'C', but now I see that bug 616767 is about apport not starting under those conditions. (I haven't dug through to see if these different workarounds succeeded or failed with different versions of apport.)

Thanks.

Revision history for this message
Michael Culbertson (michael-culbertson) wrote :

I received the smae error, though I have an English locale (LANG=en_US.UTF-8, fresh install of 12.10). Editing problem_report.py as indicated worked for me.

Changed in apport (Ubuntu):
assignee: nobody → Bruce Pieterse (octoquad)
Revision history for this message
Bruce Pieterse (octoquad) wrote :

I am unable to reproduce this error on my computer where it originally occurred as I have now upgraded to Raring to fix my frequent GPU hangs in Quantal.

Regarding the workaround posted by the bug reporter, that workaround did not work for me :(.

If anybody else would like to tackle this problem, please feel free to do so.

Changed in apport (Ubuntu):
assignee: Bruce Pieterse (octoquad) → nobody
summary: apport-collect crash when sending log file and using a non-English
- locale
+ locale ("TypeError: 'unicode' does not have the buffer interface")
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.