crash with AssertionError: file stream must be in binary mode when trying to save report to file

Bug #1007826 reported by Iain Lane
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
apport (Ubuntu)
Fix Released
High
Martin Pitt
Precise
Won't Fix
Undecided
Unassigned

Bug Description

laney@raleigh> sudo apport-cli nova-common
[...]
What would you like to do? Your options are:
  S: Send report (4.5 KB)
  V: View report
  K: Keep report file for sending later or copying to somewhere else
  I: Cancel and ignore future crashes of this program version
  C: Cancel
Please choose (S/V/K/I/C): k
Traceback (most recent call last):
  File "/usr/bin/apport-cli", line 366, in <module>
    if not app.run_argv():
  File "/usr/lib/python2.7/dist-packages/apport/ui.py", line 558, in run_argv
    return self.run_report_bug()
  File "/usr/lib/python2.7/dist-packages/apport/ui.py", line 399, in run_report_bug
    response = self.ui_present_report_details(allowed_to_report)
  File "/usr/bin/apport-cli", line 216, in ui_present_report_details
    self.report.write(os.fdopen(fd, 'w'))
  File "/usr/lib/python2.7/dist-packages/problem_report.py", line 250, in write
    self._assert_bin_mode(file)
  File "/usr/lib/python2.7/dist-packages/problem_report.py", line 628, in _assert_bin_mode
    assert (type(file) == BytesIO or 'b' in file.mode), 'file stream must be in binary mode'
AssertionError: file stream must be in binary mode

laney@raleigh> apt-cache policy apport
apport:
  Installed: 2.1.1-0ubuntu2
  Candidate: 2.1.1-0ubuntu2
  Version table:
 *** 2.1.1-0ubuntu2 0
        500 http://archive.ubuntu.com/ubuntu/ quantal/main amd64 Packages
        100 /var/lib/dpkg/status

Martin Pitt (pitti)
Changed in apport (Ubuntu):
status: New → Fix Committed
importance: Undecided → High
assignee: nobody → Martin Pitt (pitti)
Revision history for this message
Launchpad Janitor (janitor) wrote :

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

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

  * debian/tests/control: Simplify Depends: line by using "@" and dropping
    packages which are already dependencies of apport's packages.
  * debian/tests/control: Drop undefined "no-build-needed" feature.
  * New upstream bug fix release. Changes since our previous trunk snapshot:
    - apport-cli: Unbreak "keep" option. (LP: #1007826)
    - launchpad.py: Fix str vs. bytes crash for already known bugs.
      (LP: #1015788)
 -- Martin Pitt <email address hidden> Thu, 21 Jun 2012 09:13:56 +0200

Changed in apport (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Michael Schaller (misch-9) wrote :

I'm seeing this issue when I do a dist-upgrade via python-apt from Precise to Trusty. Can the fix be backported to Precise?

Log snippet:
2014-04-25 11:34:17 INFO: apt: Processing package kdesdk-scripts (0.2040%)
2014-04-25 11:34:17 DEBUG: dpkg: Unpacking kdesdk-scripts (4:4.13.0-0ubuntu1) over (4:4.8.5-0ubuntu0.1) ...
2014-04-25 11:34:17 DEBUG: dpkg: dpkg: error processing archive /var/cache/apt/archives/kdesdk-scripts_4%3a4.13.0-0ubuntu1_all.deb (--unpack):
2014-04-25 11:34:17 DEBUG: dpkg: trying to overwrite '/usr/bin/extractattr', which is also in package pkg-kde-tools 0.14.2ubuntu5
2014-04-25 11:34:17 DEBUG: dpkg: dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
2014-04-25 11:34:17 ERROR: apt: trying to overwrite '/usr/bin/extractattr', which is also in package pkg-kde-tools 0.14.2ubuntu5
2014-04-25 11:34:17 DEBUG: dpkg: Errors were encountered while processing:
2014-04-25 11:34:17 DEBUG: dpkg: /var/cache/apt/archives/kdesdk-scripts_4%3a4.13.0-0ubuntu1_all.deb
2014-04-25 11:34:18 DEBUG: dpkg: Error in function:
2014-04-25 11:34:18 DEBUG: dpkg: SystemError: E:Sub-process /usr/bin/dpkg returned an error code (1)
2014-04-25 11:34:18 DEBUG: dpkg: Error in sys.excepthook:
2014-04-25 11:34:18 DEBUG: dpkg: Traceback (most recent call last):
2014-04-25 11:34:18 DEBUG: dpkg: File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 114, in apport_excepthook
2014-04-25 11:34:18 DEBUG: dpkg: mangled_program = re.sub('/', '_', binary)
2014-04-25 11:34:18 DEBUG: dpkg: File "/usr/lib/python2.7/dist-packages/apport/fileutils.py", line 256, in get_recent_crashes
2014-04-25 11:34:18 DEBUG: dpkg: pr.load(report, False)
2014-04-25 11:34:18 DEBUG: dpkg: File "/usr/lib/python2.7/dist-packages/problem_report.py", line 124, in load
2014-04-25 11:34:18 DEBUG: dpkg: self._assert_bin_mode(file)
2014-04-25 11:34:18 DEBUG: dpkg: File "/usr/lib/python2.7/dist-packages/problem_report.py", line 631, in _assert_bin_mode
2014-04-25 11:34:18 DEBUG: dpkg: assert (type(file) == BytesIO or 'b' in file.mode), 'file stream must be in binary mode'
2014-04-25 11:34:18 DEBUG: dpkg: AssertionError: file stream must be in binary mode
2014-04-25 11:34:18 DEBUG: dpkg:
2014-04-25 11:34:18 DEBUG: dpkg: Original exception was:
2014-04-25 11:34:18 DEBUG: dpkg: SystemError: E:Sub-process /usr/bin/dpkg returned an error code (1)
2014-04-25 11:34:18 INFO: apt: End of package operation

Revision history for this message
Iain Lane (laney) wrote :

Michael,

Thanks. I've backported the fix to Precise now.

What this bug needs that I'm hoping you can help me to provide is steps to reproduce the problem. I tried in a chroot with the examples in your log but I couldn't get it to happen. Could reproduce the upgrade failure though (did you report that?).

Can you provide a reproduction recipe? It's so that the update can be verified to fix what it says it does. They won't accept it without that, sadly.

Thanks!

Revision history for this message
Iain Lane (laney) wrote :

(ah, I just saw a new kde-dev-tools with what looks like this fix come in)

Revision history for this message
Michael Schaller (misch-9) wrote :

Hi Iain,

Sorry for the delay on this one.
So far I am completely unable to come up with reproduction steps but I can reproduce it with my Python dist-upgrade script with each run. Unfortunately I can't simply release the script to public and the script is quite complex as it is completely unattended and uses custom Progress classes for apt/dpkg logging.

Can't you release the updates package to precise-proposed? Then I can report back if the issue is fixed.

Best,

Michael

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

Yes, Iain has already uploaded the fix to the precise queue. It needs the SRU team to review/accept:
https://launchpad.net/ubuntu/precise/+queue?queue_state=1

Changed in apport (Ubuntu Precise):
status: New → In Progress
Iain Lane (laney)
Changed in apport (Ubuntu Precise):
status: In Progress → Confirmed
Revision history for this message
Michael Schaller (misch-9) wrote :

Iain, what is the current state for Precise?
Is there a proposed package that I could test?

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

The Precise Pangolin has reached end of life, so this bug will not be fixed for that release

Changed in apport (Ubuntu Precise):
status: Confirmed → Won't Fix
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.