report's _command_output function doesn't always return the error

Bug #1579897 reported by Brian Murray
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Apport
Fix Released
Medium
Martin Pitt
apport (Ubuntu)
Fix Released
Low
Unassigned

Bug Description

Apparently, the following gdb command fails but the error output is not in subprocess's err output but in stdout.

> /srv/daisy.staging.ubuntu.com/staging/apport-2984/apport/report.py(104)_command_output()
-> if sp.returncode == 0:
(Pdb) l
 99 '''
100 sp = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=stderr)
101
102 (out, err) = sp.communicate(input)
103 import pdb; pdb.set_trace()
104 -> if sp.returncode == 0:
105 return out
106 else:
107 if err:
108 err = err.decode('UTF-8', errors='replace')
109 else:
(Pdb) command
['/tmp/apport_sandbox__6uwrvhm/usr/bin/gdb', '--ex', 'set debug-file-directory /tmp/apport_sandbox__6uwrvhm/usr/lib/debug', '--ex', 'set solib-absolute-prefix /tmp/apport_sandbox__6uwrvhm', '--ex', 'file "/tmp/apport_sandbox__6uwrvhm//usr/bin/cdparanoia"', '--ex', 'core-file /tmp/apport_core_756rypvb', '--batch', '--ex', 'set backtrace limit 2000', '--ex', 'p -99', '--ex', 'print (char*) __nih_abort_msg', '--ex', 'p -99', '--ex', 'print __abort_msg->msg', '--ex', 'p -99', '--ex', 'print __glib_assert_msg', '--ex', 'p -99', '--ex', 'bt full', '--ex', 'p -99', '--ex', 'x/16i $pc', '--ex', 'p -99', '--ex', 'thread apply all bt full', '--ex', 'p -99', '--ex', 'info registers']
(Pdb) out
b'/tmp/apport_sandbox__6uwrvhm/usr/bin/gdb: error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory\n'

Because stdout is not included in the raised error message it ended up being hard to find out what the error really was.

111 raise OSError('Error: command %s failed with exit code %i: %s' % (
112 str(command), sp.returncode, err))

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

This is because _command_output() defaults to stderr=subprocess.STDOUT, so we'll never see the error on stderr indeed.

Changed in apport:
assignee: nobody → Martin Pitt (pitti)
importance: Undecided → Medium
status: New → In Progress
Revision history for this message
Martin Pitt (pitti) wrote :

Reproduced with "sudo dpkg --force-all -P libbabeltrace1" which breaks gdb (but keeps python3.5 intact).

Fixed in http://bazaar.launchpad.net/~apport-hackers/apport/trunk/revision/3079

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

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

---------------
apport (2.20.2-0ubuntu1) yakkety; urgency=medium

  [ Brian Murray ]
  * data/general-hooks/ubuntu.py: tag bug reports 'apport-hook-error' if they
    have an attachment from an apport hook which crashed.

  [ Martin Pitt ]
  * New upstream release. Changes since our previous snapshot:
    - Don't ignore OSError in Report.add_gdb_info(), as we do want to fail with an
      useful error message if gdb cannot be called in apport-retrace. Move the
      catching to the UI as not having gdb installed is still fine for reporting
      clients. (LP: #1579949)
    - Show gdb error messages in Report.add_gdb_info() OSError exception when gdb
      fails. (LP: #1579897)
    - hookutils, attach_root_command_outputs(): Return str again, like before
      2.15.2. (LP: #1370259)
    - Stop issuing "set architecture" gdb commands on ARM and Power; these only
      applied to 32 bit platforms and are apparently not needed any more with
      recent gdb versions. (LP: #1585702)
    - Disable report.test_add_gdb_info_abort_libnih test case for now, as libnih
      is broken under current Ubuntu (LP: #1580601)

 -- Martin Pitt <email address hidden> Sun, 19 Jun 2016 22:17:35 +0200

Changed in apport (Ubuntu):
status: Fix Committed → Fix Released
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.