/usr/share/apport/apport:AttributeError:/usr/share/apport/apport@451:parse_arguments:print_usage:_print_message

Bug #1899195 reported by errors.ubuntu.com bug bridge
38
This bug affects 3 people
Affects Status Importance Assigned to Milestone
apport (Ubuntu)
Fix Released
High
Brian Murray
Xenial
Fix Released
High
Brian Murray
Bionic
Fix Released
High
Brian Murray
Focal
Fix Released
High
Brian Murray

Bug Description

Impact
------
apport is crashing for some users when a crash file is created about an executable which has been deleted.

Test Case
---------
While you won't get a Traceback (because there is a location for apport to print its usages message) with the following test case you will see apport usage printed:

 $ PYTHONPATH=/home/bdmurray/source-trees/apport/trunk data/apport '8219' '11' '0' '1' '8219' '!usr!bin!yes' '(deleted)'
usage: apport [-h] [-p PID] [-s SIGNAL_NUMBER] [-c CORE_ULIMIT] [-d DUMP_MODE] [-P [GLOBAL_PID]]

With the fixed version of apport you'll see no such usage message.

Regression Potential
--------------------
Because new code is being added its possible that the python syntax could be bad which would result in another crash, so careful review the code.

Original Description
--------------------
The Ubuntu Error Tracker has been receiving reports about a problem regarding apport. This problem was most recently seen with package version 2.20.11-0ubuntu27.10, the problem page at https://errors.ubuntu.com/problem/290470c9cf5f278596966c386aac31e70a49988e contains more details, including versions of packages affected, stacktrace or traceback, and individual crash reports.

Traceback (most recent call last):
  File "/usr/share/apport/apport", line 451, in <module>
    options = parse_arguments()
  File "/usr/share/apport/apport", line 396, in parse_arguments
    parser.print_usage()
  File "/usr/lib/python3.6/argparse.py", line 2370, in print_usage
    self._print_message(self.format_usage(), file)
  File "/usr/lib/python3.6/argparse.py", line 2381, in _print_message
    file.write(message)
AttributeError: 'NoneType' object has no attribute 'write'

After working on https://bugs.launchpad.net/apport/+bug/1732962, the error tracker started throwing the error above.
it appears that print_usage is called and throwing an error because in this context (called with core_pattern) apport doesn't have an stdout or stderr. after looking at traces it seems the kernel is adding 'deleted' to the name of the process which cause argument parsing to fail.

The fix below from bdmurray seems to fix it.
https://paste.ubuntu.com/p/pVKNP9kWP4/

There is report of this issue in Focal, Bionic and xenial

description: updated
tags: added: xenial
tags: added: test-1234
tags: removed: test-1234
tags: added: test-tag
tags: removed: test-tag
tags: added: fr-818
description: updated
Changed in apport (Ubuntu):
status: New → Confirmed
Revision history for this message
Brian Murray (brian-murray) wrote :

My patch works by ensuring the apport can handle the number of arguments being passed such that print_usage() is never called so we won't Traceback trying to write to a non-existent file.

Changed in apport (Ubuntu):
status: Confirmed → In Progress
importance: Undecided → High
assignee: nobody → Brian Murray (brian-murray)
Revision history for this message
Brian Murray (brian-murray) wrote :

While you won't get a Traceback with the following test case you will see apport usage printed:

 $ PYTHONPATH=/home/bdmurray/source-trees/apport/trunk data/apport '8219' '11' '0' '1' '8219' '!usr!share!spotify!spotify' '(deleted)'
usage: apport [-h] [-p PID] [-s SIGNAL_NUMBER] [-c CORE_ULIMIT] [-d DUMP_MODE] [-P [GLOBAL_PID]]

With the fixed version of apport you'll see no such usage message.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package apport - 2.20.11-0ubuntu50

---------------
apport (2.20.11-0ubuntu50) groovy; urgency=medium

  * etc/apport/crashdb.conf: Disable Launchpad crash reports for 20.10
    release.
  * data/apport: In the event that the crashing executable does not exist on
    disk any more the path name of the executable (passed by core) is appended
    with '(deleted)' because apport is currently using sys.argv for argument
    parsing there end up being too many arguments and apport crashes. This is
    fixed by adding handling for six arguments. (LP: #1899195)

 -- Brian Murray <email address hidden> Mon, 12 Oct 2020 13:44:05 -0700

Changed in apport (Ubuntu):
status: In Progress → Fix Released
Changed in apport (Ubuntu Xenial):
status: New → Triaged
Changed in apport (Ubuntu Bionic):
status: New → Triaged
Changed in apport (Ubuntu Focal):
status: New → Triaged
Changed in apport (Ubuntu Xenial):
importance: Undecided → High
Changed in apport (Ubuntu Bionic):
importance: Undecided → High
Changed in apport (Ubuntu Focal):
importance: Undecided → High
Changed in apport (Ubuntu Focal):
assignee: nobody → Brian Murray (brian-murray)
Changed in apport (Ubuntu Bionic):
assignee: nobody → Brian Murray (brian-murray)
Changed in apport (Ubuntu Focal):
status: Triaged → In Progress
Changed in apport (Ubuntu Bionic):
status: Triaged → In Progress
Changed in apport (Ubuntu Xenial):
status: Triaged → In Progress
assignee: nobody → Brian Murray (brian-murray)
description: updated
Revision history for this message
Robie Basak (racb) wrote : Proposed package upload rejected

An upload of apport to focal-proposed has been rejected from the upload queue for the following reason: "Symlinks appear inadvertently flattened; for example bin/apport-collect has changed from a symlink to a flat file.".

Revision history for this message
Robie Basak (racb) wrote :

An upload of apport to bionic-proposed has been rejected from the upload queue for the following reason: "Symlinks appear inadvertently flattened; for example bin/apport-collect has changed from a symlink to a flat file.".

Revision history for this message
Robie Basak (racb) wrote : Please test proposed package

Hello errors.ubuntu.com, or anyone else affected,

Accepted apport into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/apport/2.20.1-0ubuntu2.26 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-xenial to verification-done-xenial. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-xenial. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in apport (Ubuntu Xenial):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-xenial
Revision history for this message
Robie Basak (racb) wrote :

Hello errors.ubuntu.com, or anyone else affected,

Accepted apport into focal-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/apport/2.20.11-0ubuntu27.11 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-focal to verification-done-focal. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-focal. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in apport (Ubuntu Focal):
status: In Progress → Fix Committed
tags: added: verification-needed-focal
Revision history for this message
Robie Basak (racb) wrote :

Hello errors.ubuntu.com, or anyone else affected,

Accepted apport into bionic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/apport/2.20.9-0ubuntu7.19 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-bionic to verification-done-bionic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-bionic. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in apport (Ubuntu Bionic):
status: In Progress → Fix Committed
tags: added: verification-needed-bionic
Revision history for this message
Ubuntu SRU Bot (ubuntu-sru-bot) wrote : Autopkgtest regression report (apport/2.20.1-0ubuntu2.26)

All autopkgtests for the newly accepted apport (2.20.1-0ubuntu2.26) for xenial have finished running.
The following regressions have been reported in tests triggered by the package:

apport/2.20.1-0ubuntu2.26 (i386)

Please visit the excuses page listed below and investigate the failures, proceeding afterwards as per the StableReleaseUpdates policy regarding autopkgtest regressions [1].

https://people.canonical.com/~ubuntu-archive/proposed-migration/xenial/update_excuses.html#apport

[1] https://wiki.ubuntu.com/StableReleaseUpdates#Autopkgtest_Regressions

Thank you!

Revision history for this message
Brian Murray (brian-murray) wrote :

Verification passed on Ubuntu 20.04 LTS.

bdmurray@clean-focal-amd64:~$ apt list apport
Listing... Done
apport/focal-updates,focal-updates,now 2.20.11-0ubuntu27.10 all [installed]
N: There are 2 additional versions. Please use the '-a' switch to see them.
bdmurray@clean-focal-amd64:~$ /usr/share/apport/apport '8219' '11' '0' '1' '8219' '!usr!bin!yes' '(deleted)'
usage: apport [-h] [-p PID] [-s SIGNAL_NUMBER] [-c CORE_ULIMIT] [-d DUMP_MODE] [-P [GLOBAL_PID]] [-E [EXECUTABLE_PATH]]
bdmurray@clean-focal-amd64:~$ sudo apt-get update &> /dev/null; sudo apt-get install apport python3-apport &> /dev/null
bdmurray@clean-focal-amd64:~$ apt list apport
Listing... Done
apport/focal-proposed,focal-proposed,now 2.20.11-0ubuntu27.11 all [installed]
N: There are 3 additional versions. Please use the '-a' switch to see them.
bdmurray@clean-focal-amd64:~$ /usr/share/apport/apport '8219' '11' '0' '1' '8219' '!usr!bin!yes' '(deleted)'
ERROR: apport (pid 2571) Thu Oct 29 10:06:17 2020: cannot create lock file (uid 1000): [Errno 13] Permission denied: '/var/run/apport.lock'

Revision history for this message
Brian Murray (brian-murray) wrote :

Verification passed on Ubuntu 18.04 LTS.

bdmurray@clean-bionic-amd64:~$ apt list apport
Listing... Done
apport/bionic-proposed,bionic-proposed 2.20.9-0ubuntu7.19 all [upgradable from: 2.20.9-0ubuntu7.18]
N: There are 3 additional versions. Please use the '-a' switch to see them.
bdmurray@clean-bionic-amd64:~$ /usr/share/apport/apport '8219' '11' '0' '1' '8219' '!usr!bin!yes' '(deleted)'
usage: apport [-h] [-p PID] [-s SIGNAL_NUMBER] [-c CORE_ULIMIT] [-d DUMP_MODE]
              [-P [GLOBAL_PID]] [-E [EXECUTABLE_PATH]]
bdmurray@clean-bionic-amd64:~$ sudo apt-get update &> /dev/null; sudo apt-get install apport python3-apport &> /dev/null
bdmurray@clean-bionic-amd64:~$ apt list apport
Listing... Done
apport/bionic-proposed,bionic-proposed,now 2.20.9-0ubuntu7.19 all [installed,automatic]
N: There are 3 additional versions. Please use the '-a' switch to see them.
bdmurray@clean-bionic-amd64:~$ /usr/share/apport/apport '8219' '11' '0' '1' '8219' '!usr!bin!yes' '(deleted)'
ERROR: apport (pid 2868) Thu Oct 29 10:11:04 2020: cannot create lock file (uid 1000): [Errno 13] Permission denied: '/var/run/apport.lock'

Revision history for this message
Brian Murray (brian-murray) wrote :

Verification passed on Ubuntu 16.04 LTS.

bdmurray@clean-xenial-amd64:~$ apt list apport
Listing... Done
apport/xenial-updates,xenial-updates,xenial-security,xenial-security,now 2.20.1-0ubuntu2.23 all [installed]
N: There is 1 additional version. Please use the '-a' switch to see it
bdmurray@clean-xenial-amd64:~$ /usr/share/apport/apport '8219' '11' '0' '1' '8219' '!usr!bin!yes' '(deleted)'
Usage: /usr/share/apport/apport <pid> <signal number> <core file ulimit> <dump mode> [global pid] [exe path]
The core dump is read from stdin.
bdmurray@clean-xenial-amd64:~$ sudo apt-get update &> /dev/null; sudo apt-get install apport &> /dev/null

bdmurray@clean-xenial-amd64:~$ apt list apport
Listing... Done
apport/xenial-proposed,xenial-proposed,now 2.20.1-0ubuntu2.26 all [installed]
N: There are 3 additional versions. Please use the '-a' switch to see them.
bdmurray@clean-xenial-amd64:~$ /usr/share/apport/apport '8219' '11' '0' '1' '8219' '!usr!bin!yes' '(deleted)'
ERROR: apport (pid 2644) Thu Oct 29 10:20:50 2020: cannot create lock file (uid 1000): [Errno 13] Permission denied: '/var/run/apport.lock'

tags: added: verification-done verification-done-bionic verification-done-focal verification-done-xenial
removed: verification-needed verification-needed-bionic verification-needed-focal verification-needed-xenial
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Update Released

The verification of the Stable Release Update for apport has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package apport - 2.20.11-0ubuntu27.11

---------------
apport (2.20.11-0ubuntu27.11) focal; urgency=medium

  * data/apport: In the event that the crashing executable does not exist on
    disk any more the path name of the executable (passed by core) is appended
    with '(deleted)' because apport is currently using sys.argv for argument
    parsing there end up being too many arguments and apport crashes. This is
    fixed by adding handling for six arguments. (LP: #1899195)

 -- Brian Murray <email address hidden> Fri, 16 Oct 2020 13:30:49 -0700

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

This bug was fixed in the package apport - 2.20.9-0ubuntu7.19

---------------
apport (2.20.9-0ubuntu7.19) bionic; urgency=medium

  * data/apport: In the event that the crashing executable does not exist on
    disk any more the path name of the executable (passed by core) is appended
    with '(deleted)' because apport is currently using sys.argv for argument
    parsing there end up being too many arguments and apport crashes. This is
    fixed by adding handling for six arguments. (LP: #1899195)

 -- Brian Murray <email address hidden> Fri, 16 Oct 2020 13:34:10 -0700

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

This bug was fixed in the package apport - 2.20.1-0ubuntu2.26

---------------
apport (2.20.1-0ubuntu2.26) xenial; urgency=medium

  * data/apport: In the event that the crashing executable does not exist on
    disk any more the path name of the executable (passed by core) is appended
    with '(deleted)' because apport is currently using sys.argv for argument
    parsing there end up being too many arguments and apport crashes. This is
    fixed by adding handling for six arguments. (LP: #1899195)

 -- Brian Murray <email address hidden> Mon, 19 Oct 2020 09:22:56 -0700

Changed in apport (Ubuntu Xenial):
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.