apport-unpack requires too much main memory to run

Bug #1307413 reported by Louis Bouchard
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
apport (Ubuntu)
Fix Released
Medium
Unassigned
Precise
Invalid
Medium
Unassigned

Bug Description

when running apport-unpack on large apport reports (linux-image kernel dumps is a good example), it requires an enormous amount of main memory to run.

An example is a 1.3Gb apport report that runs for more than 24 hours with more than 4Gb of RSS.

The command should requires less memory to extract those big reports.

Tags: cts

Related branches

Louis Bouchard (louis)
Changed in apport (Ubuntu):
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → Louis Bouchard (louis-bouchard)
Revision history for this message
Chris J Arges (arges) wrote :

I get a similar issue for apport-retrace with extremely large CoreDump files:

$ apport-retrace -R -v -g --sandbox=sandbox _usr_bin_qemu-system-x86_64.0.crash
Traceback (most recent call last):
  File "/usr/bin/apport-retrace", line 321, in <module>
    report.add_package_info()
  File "/usr/lib/python2.7/dist-packages/apport/report.py", line 214, in add_package_info
    package = apport.fileutils.find_file_package(self['ExecutablePath'])
  File "/usr/lib/python2.7/dist-packages/apport/fileutils.py", line 88, in find_file_package
    return packaging.get_file_package(file)
  File "/usr/lib/python2.7/dist-packages/apport/packaging_impl.py", line 307, in get_file_package
    stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1143, in _execute_child
    self.pid = os.fork()
OSError: [Errno 12] Cannot allocate memory

Revision history for this message
Louis Bouchard (louis) wrote :

Just for the record : I have here a qemu-kvm apport which is 12 Gb in size and requires 57 GB of swap space to unpack.

Louis Bouchard (louis)
tags: added: cts
Revision history for this message
Louis Bouchard (louis) wrote :

After taking a long look at the code, it appears that ProblemReport.load() method brings everything from the report in memory. While this is acceptable for normal crashes, it becomes particularly difficult for kernel crash dumps that are often multi Gb.

Since Raring, kernel crash dumps are no longer stored in the apport report so this is not an issue. But for all kernel crashes happening on Precise, this _is_ a problem.

My proposal is to add a ProblemReport.extract() method that will read the report and write the binary content to disk.

A first pass is done by loading the report with binary=False. This will NOT load the binary elements of the report. Those will be identified while writing the other elements of the report and then used in conjunction with ProblemReport.extract to write only those binary content directly to a file.

I will propose a merge for that shortly

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

Merged into trunk with a few cleanups: http://bazaar.launchpad.net/~apport-hackers/apport/trunk/revision/2896

Thanks!

Changed in apport (Ubuntu):
status: In Progress → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

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

---------------
apport (2.16-0ubuntu1) vivid; urgency=medium

  * New upstream release:
    - Add a new method ProblemReport.extract_keys() which writes binary keys
      (which can be very large) directly to files without loading them all
      into memory first. Use that in apport-unpack. Thanks Louis Bouchard!
      (LP: #1307413)
    - launchpad backend: Work with Python 3, now that launchpadlib exists for
      Python 3. (LP: #1153671)
    - apport-bug, apport-gtk: Also check for $WAYLAND_SESSION, to use
      apport-gtk instead of apport-cli under Wayland. Thanks Tim Lunn.
      (LP: #1418766)
    - apport-gtk: When running under Wayland, avoid Gdk/Wnck operation for
      setting crash window modal to the PID of the crashed window; these only
      work under X11.
    - Don't install the test suite any more, to save 1 MB of installed space.
      It can be run out of trunk easily enough, and distributions can install
      it from tests/ if they desire.
    - hookutils, attach_root_command_outputs(): Fix UnicodeDecodeError crash
      for non-textual values. (LP: #1370259)
    - ui.py: Only provide a UI to hooks if the crash db will accept the
      report. This avoids asking questions if the report is merely sent to
      whoopsie for Ubuntu stable releases. Thanks Brian Murrary.
      (LP: #1084979)
    - whoopsie-upload-all: Add package information to the report before
      calling package hooks. Thanks Brian Murray.
    - Fix check for available terminal when checking whether to display the
      "Examine locally" button.
  * Add general hook for detecting Wayland sessions and tagging them with
    "wayland-session". Thanks Timm Lunn! (LP: #1418262)
  * debian/tests/upstream-system: Copy tests from source tree, as
    /usr/share/apport/testsuite/ does not exist any more.
 -- Martin Pitt <email address hidden> Fri, 06 Feb 2015 10:11:30 +0100

Changed in apport (Ubuntu):
status: Fix Committed → Fix Released
Louis Bouchard (louis)
Changed in apport (Ubuntu Precise):
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → Louis Bouchard (louis-bouchard)
Revision history for this message
Louis Bouchard (louis) wrote :

After discussion with upstream; doing the SRU to precise for such a corner case is a waste of time. The Vivid package is available if the change is _really_ needed.

Marking the precise task invalid

Changed in apport (Ubuntu Precise):
status: Confirmed → Invalid
assignee: Louis Bouchard (louis-bouchard) → nobody
Changed in apport (Ubuntu):
assignee: Louis Bouchard (louis-bouchard) → nobody
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.