Software-Center crash at launch if apt-history gzip archives are corrupted

Bug #725186 reported by Jean-Alexandre Anglès d'Auriac
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
software-center (Ubuntu)
Fix Released
Medium
Olivier Tilloy
Maverick
Fix Released
Medium
Gary Lasker

Bug Description

Binary package hint: software-center

If the apt history gzip archives contained in /var/log/apt/ are corrupted, then Software-Center crash at launch.
I attached the corrupted archive that triggered the bug on my laptop.

---
TEST CASE (for Maverick SRU):

1. Run Maverick.
2. In a terminal, type the following commands to temporarily swap in a corrupted apt history file (the original will be restored after):

  wget https://bugs.launchpad.net/ubuntu/+source/software-center/+bug/725186/+attachment/1871475/+files/history.log.5.gz
  sudo mv /var/log/apt/history.log.1.gz /var/log/apt/history.log.1.gz.SAVE
  sudo cp history.log.5.gz /var/log/apt/history.log.1.gz

3. Launch Software Center by typing the following into a terminal (this will allow you to verify the error output):

  software-center

4. Verify that software-center crashes (does not start) and the error output in the terminal ends with:

  "zlib.error: Error -3 while decompressing: invalid distance too far back"

5. Install the updated version of Software Center (3.0.9) from maverick-proposed.
6. Launch Software Center again from the terminal (or directly) and verify that Software Center now launches correctly (the main window is displayed, etc.).
7. Type the following in a terminal to restore your previous apt history log:

  sudo mv /var/log/apt/history.log.1.gz.SAVE /var/log/apt/history.log.1.gz

Related branches

Revision history for this message
Jean-Alexandre Anglès d'Auriac (jagw40k) wrote :
Revision history for this message
Olivier Tilloy (osomon) wrote :

Thanks for the report. I can confirm the issue with S-C 3.0.7 in maverick.
The issue was fixed in the trunk at revision 1284, available in S-C ≥ 3.1.1.
We may want to backport the fix to Maverick though, as it is a crasher that renders S-C unusable.

Changed in software-center (Ubuntu):
status: New → Fix Released
Revision history for this message
Olivier Tilloy (osomon) wrote :

Here is the traceback generated on Maverick:

Traceback (most recent call last):
  File "/usr/bin/software-center", line 90, in <module>
    app = SoftwareCenterApp(datadir, xapian_base_path, options, args)
  File "/usr/share/software-center/softwarecenter/app.py", line 149, in __init__
    self.history = get_apt_history()
  File "/usr/share/software-center/softwarecenter/apt/apthistory.py", line 178, in get_apt_history
    apt_history = AptHistory()
  File "/usr/share/software-center/softwarecenter/apt/apthistory.py", line 83, in __init__
    self.rescan()
  File "/usr/share/software-center/softwarecenter/apt/apthistory.py", line 98, in rescan
    self._scan(history_gz_file)
  File "/usr/share/software-center/softwarecenter/apt/apthistory.py", line 110, in _scan
    for stanza in deb822.Deb822.iter_paragraphs(f):
  File "/usr/lib/pymodules/python2.6/debian/deb822.py", line 287, in iter_paragraphs
    x = cls(iterable, fields, encoding=encoding)
  File "/usr/lib/pymodules/python2.6/debian/deb822.py", line 255, in __init__
    self._internal_parser(sequence, fields)
  File "/usr/lib/pymodules/python2.6/debian/deb822.py", line 308, in _internal_parser
    for line in self.gpg_stripped_paragraph(sequence):
  File "/usr/lib/pymodules/python2.6/debian/deb822.py", line 551, in gpg_stripped_paragraph
    return cls.split_gpg_and_payload(sequence)[1]
  File "/usr/lib/pymodules/python2.6/debian/deb822.py", line 503, in split_gpg_and_payload
    for line in sequence:
  File "/usr/lib/python2.6/gzip.py", line 438, in next
    line = self.readline()
  File "/usr/lib/python2.6/gzip.py", line 393, in readline
    c = self.read(readsize)
  File "/usr/lib/python2.6/gzip.py", line 219, in read
    self._read(readsize)
  File "/usr/lib/python2.6/gzip.py", line 271, in _read
    uncompress = self.decompress.decompress(buf)
zlib.error: Error -3 while decompressing: invalid distance too far back

Revision history for this message
Olivier Tilloy (osomon) wrote :

I’m not sure how to mark the bug as affecting Maverick and fixed in Natty, and it seems I cannot change the bug status now that I’ve marked it 'Fix Released'…
Anyway, I’m attaching a patch against lp:ubuntu/maverick-updates/software-center that fixes the crash.

Revision history for this message
Gary Lasker (gary-lasker) wrote :

Heya Olivier! :) Thanks a lot for the patch. I applied it to a branch for 3.0 and nominated this bug for maverick. This is good timing as we have another fix that we need to cherrypick for an SRU as well (bug 684077).

Thanks again!
Gary

Revision history for this message
Olivier Tilloy (osomon) wrote :

Awesome, thanks for your swiftness Gary!

Changed in software-center (Ubuntu):
importance: Undecided → Medium
Changed in software-center (Ubuntu Maverick):
status: New → Fix Committed
importance: Undecided → Medium
description: updated
description: updated
Changed in software-center (Ubuntu Maverick):
assignee: nobody → Gary Lasker (gary-lasker)
description: updated
description: updated
Changed in software-center (Ubuntu Maverick):
milestone: none → maverick-updates
Revision history for this message
Martin Pitt (pitti) wrote : Please test proposed package

Accepted software-center into maverick-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

tags: added: verification-needed
Changed in software-center (Ubuntu):
assignee: nobody → Olivier Tilloy (osomon)
Revision history for this message
Gary Lasker (gary-lasker) wrote :

I have verified this fix in software-center version 3.0.9 in maverick-proposed per the stated test procedure, and all seems fine. Thanks!

tags: added: verification-done
removed: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package software-center - 3.0.9

---------------
software-center (3.0.9) maverick-proposed; urgency=low

  [ Gary Lasker ]
  * softwarecenter/db/update.py,
    test/test_appview.py,
    test/test_database.py:
    - track cataloged_time for items not in axi (e.g. for-purchase apps)
      so that they will show up in What's New, add/modify unit tests
      per the changes (LP: #684077)
    - fix icon display that have a "." in it (LP: #745942)
  * softwarecenter/db/update.py,
    softwarecenter/view/appdetailsview_gtk.py,
    test/test_downloader.py:
    - fix screenshot issues for apps for purchase and update unit
      test (LP: #791932)

  [ Olivier Tilloy ]
  * softwarecenter/apt/apthistory.py:
    - fix startup crash if the history file is corrupted (LP: #725186)
 -- Gary Lasker <email address hidden> Wed, 15 Jun 2011 22:35:43 -0400

Changed in software-center (Ubuntu Maverick):
status: Fix Committed → Fix Released
tags: added: testcase
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.