apport-gtk crashed with TypeError in _check_bug_pattern(): can't use a string pattern on a bytes-like object

Bug #1016380 reported by crf
128
This bug affects 25 people
Affects Status Importance Assigned to Milestone
apport (Ubuntu)
Medium
Martin Pitt

Bug Description

crashed when reporting a particular bug.
I'm using quantal.

ProblemType: Crash
DistroRelease: Ubuntu 12.10
Package: apport-gtk 2.2.5-0ubuntu1
ProcVersionSignature: Ubuntu 3.4.0-5.11-generic 3.4.0
Uname: Linux 3.4.0-5-generic x86_64
ApportVersion: 2.2.5-0ubuntu1
Architecture: amd64
CrashCounter: 1
Date: Thu Jun 21 22:51:10 2012
ExecutablePath: /usr/share/apport/apport-gtk
InterpreterPath: /usr/bin/python3.2mu
PackageArchitecture: all
ProcCmdline: /usr/bin/python3 /usr/share/apport/apport-gtk
PythonArgs: ['/usr/share/apport/apport-gtk']
SourcePackage: apport
Title: apport-gtk crashed with TypeError in _check_bug_pattern(): can't use a string pattern on a bytes-like object
UpgradeStatus: Upgraded to quantal on 2012-06-18 (3 days ago)
UserGroups:

Related branches

Revision history for this message
crf (chrisfahlman) wrote :
tags: removed: need-duplicate-check
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 :

Here is a crash file that triggered this apport problem.

It was a dpkg run where conflicting packages provided the same file. Offhand, the crash file has a terminal log of the dpkg session, a lot of text with control characters embedded in it. I suppose these ^M's could be causing a problem of binary where text is expected. But that's probably something apport has had to deal with long before. Thanks.

Revision history for this message
Edward Donovan (edward.donovan) wrote :

Well, in addition to the speculation in my last comment being a pretty weak idea, anyway, other people managed to report that crash, bug 1017289, with apport. And I see that my crash file has lots of older bits of log in it, too. So I'll retreat to a firmer "I don't know."

Revision history for this message
Linuxexperte (andrea-koeth) wrote :

Can confirm the same thing here in Ubunt u12.10 Gnome-Shell 3.5. This came with the current update at about 20:53 CET. And in addition to this problem with apport, a second error occured referring to evince. I just reported this error referring to evince. And perhaps, these two things have to do someting with each other...but this is also speculation.

Greetings
Linuxexperte

Revision history for this message
josa (johnny-sander) wrote :

Got this as apport was reporting an install problem for package compiz-gnome 1:0.9.8-bzr3249-0ubuntu1 during this mornings update using synaptic in Ubuntu Quantal.

Revision history for this message
josa (johnny-sander) wrote :

In case it can be of any use the install problem mentioned in #6 above is now reported in bug 1019145 - package compiz-gnome 1:0.9.7.8-0ubuntu3 failed to install/upgrade: trying to overwrite '/usr/share/gconf/schemas/compiz-ccp.schemas', which is also in package libcompizconfig0 0.9.7.0~bzr428-0ubuntu7.

Revision history for this message
Edward Donovan (edward.donovan) wrote :

I tested apport today with the crashfile I uploaded here, that originally triggered this bug for me. There was no problem, with apport-bug or apport-cli. The version of apport hasn't changed in the meantime. So I've gotten lost in the weeds.

Does anyone else have a crashfile that will reproduce this? Thanks.

Revision history for this message
Steve Langasek (vorlon) wrote :

Seen here as well.

Changed in apport (Ubuntu):
importance: Undecided → Medium
Revision history for this message
col reilly (lupinehorror) wrote :

me too...chromium opened (even though it isn't my default browser) and crash happened.

Revision history for this message
dino99 (9d9) wrote :

Got that crash on Lubuntu i386 after having selected an other crash to report.

tags: added: i386 lubuntu
Revision history for this message
Edward Donovan (edward.donovan) wrote :

Once again, I can't make this happen consistently with the same crashfile. Guessing from the names and times, the last two commenters, like me, probably had apport crash while reporting bug 1024016. A second attempt on that crashfile ran without problem. So I guess there's probably not much use in uploading it.

It looks like it's always terminal logs that apport is handling when it breaks. Thanks.

Revision history for this message
Edward Donovan (edward.donovan) wrote :

So, this looks like a python3 porting issue. According to comments like this:

  http://stackoverflow.com/questions/5184483/python-typeerror-on-regex

what's needed is to call 're.compile' with a 'b' flag, for bytes. I'm not familiar with the code enough, to know whether we just can sprinkle that around in all the places where apport's report.py calls 're.compile'. Does anyone have a good guess? Thanks.

Revision history for this message
Edward Donovan (edward.donovan) wrote :

Version 2.4-0ubuntu1 sounds like it fixes this:

  [ Brian Murray ]
  * data/general/ubuntu.py: in trim_log deal with the fact that
    DpkgTerminalLog is a bytes object and convert it to a string object

Since I can't reproduce the crash, I couldn't exactly test that this bug is gone, but the code does look like the right thing, handling the dpkg terminal log with the b for bytes flag. So I'm going to mark this as Fix Released. Thanks.

Changed in apport (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Brian Murray (brian-murray) wrote :

While this may fix it for DpkgTerminalLog, the fix is not generic so if another attachment were to be a bytes object and a bug pattern were written for that attachment we would get the same crash. I think this code in apport/report.py needs to modified:

            if c.hasChildNodes() and c.childNodes[0].nodeType == xml.dom.Node.TEXT_NODE:
                regexp = c.childNodes[0].nodeValue
                v = report[key]
                if isinstance(v, problem_report.CompressedValue):
                    v = v.get_value()
                    regexp = regexp.encode('UTF-8')
                try:
                    re_c = re.compile(regexp)
                except:
                    continue
                if not re_c.search(v):
                    return None

Changed in apport (Ubuntu):
status: Fix Released → Triaged
Revision history for this message
Brian Murray (brian-murray) wrote :

Edward with regards to the repeatability of this issue apport modifies the .crash file during the collection process. In ui.py we can see that collect_info is only called if the crash file is missing Dependencies and that bug patterns are checked as a part of collect_info. So only the first run of apport on a crash file would check the bug patterns and cause this crash.

Changed in apport (Ubuntu):
status: Triaged → In Progress
assignee: nobody → Brian Murray (brian-murray)
Revision history for this message
Edward Donovan (edward.donovan) wrote :

Thanks, Brian! Looking back, I sure was scratching my head a lot. I never knew this important fact:

  "apport modifies the .crash file during the collection process."

Aha.

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

Fixed upstream in http://bazaar.launchpad.net/~apport-hackers/apport/trunk/revision/2482. Thanks Brian for your original patch!

Changed in apport (Ubuntu):
assignee: Brian Murray (brian-murray) → Martin Pitt (pitti)
status: In Progress → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package apport - 2.5.2-0ubuntu1

---------------
apport (2.5.2-0ubuntu1) quantal; urgency=low

  * New upstream release:
    - Fix crash on broken .desktop files. (LP: #1039889)
    - apport-gtk: For console program crashes, say "stopped" instead of
      "closed". Add a subtitle label with a hint about hanging programs.
      Thanks Matt Price and Matthew Paul Thomas!
    - report.py: Fix crash on determination of Python module path when
      examining a crash of "python -m ...".
    - apport-kde: Fix crash with undefined QString under Python 3. Thanks
      Jonathan Riddell! (LP: #1028984)
    - launchpad.py: Add missing "Pre-release Freeze" status. Thanks Brian
      Murray!
    - report.py, _check_bug_pattern(): Fix bug pattern matching against binary
      values. Thanks Brian Murray for the original patch. (LP: #1016380)
  * debian/control: Move x-terminal-emulator dependency from apport-retrace to
    -gtk and -kde. It's those which actually spawn an X terminal for
    apport-retrace to run in, and this lessens the dependencies for
    apport-retrace on server type systems.
  * Add debian/apport.maintscript: Clean up obsolete precise conffile
    /etc/apport/native-origins.d/lts-q-backports on upgrades. (LP: #1049058)
  * data/general-hooks/ubuntu.py: Fix PEP-8 errors.
 -- Martin Pitt <email address hidden> Mon, 17 Sep 2012 14:15:41 +0200

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

Duplicates of this bug

Other bug subscribers