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

Bug #1979211 reported by errors.ubuntu.com bug bridge
46
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Apport
Fix Released
High
Unassigned
apport (Ubuntu)
Fix Released
High
Unassigned
Bionic
New
Undecided
Unassigned
Focal
Fix Released
Undecided
Unassigned
Impish
Won't Fix
Undecided
Unassigned
Jammy
Fix Released
Undecided
Unassigned

Bug Description

Impact
------

As it can be seen in https://errors.ubuntu.com/problem/e714f8181c0785693f3a66969c594a3b19bcab2b there are thousands of crashes of this type (and multiple duplicate bug reports for it). Instead of apport logging a failure in /var/log/apport.log, it crashes. Fixing this bug also fixes the issue with logging failures in the socket path (for handling crashes in containers).

Test Case
---------

There should be no instances of
https://errors.ubuntu.com/problem/e714f8181c0785693f3a66969c594a3b19bcab2b
for the fixed version.

Where problems could occur
--------------------------

The apport binary is called by the kernel when a process crashes. Worst case scenarios include breaking the apport binary and no problem report is generated any more (or apport uses too much resources). Since all the desired logs are now logged, it could increase the amount of logs that are written (apport has some flood detection in case a process dies constantly).

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-0ubuntu82.1, the problem page at https://errors.ubuntu.com/problem/e714f8181c0785693f3a66969c594a3b19bcab2b contains more details, including versions of packages affected, stacktrace or traceback, and individual crash reports.
If you do not have access to the Ubuntu Error Tracker and are a software developer, you can request it at http://forms.canonical.com/reports/.

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

This bug can be reproduced by configuring the previously supported parameters to Apport and then let a process crash (e.g. call divide-by-zero):

```
echo "|/usr/share/apport/apport %p %s %c %d %P %E" | sudo tee /proc/sys/kernel/core_pattern
```

So this bug is a regression of commit c320e910a516 ("Switch to using non-positional arguments") which is a fix for CVE-2022-28658 and CVE-2021-3899.

Benjamin Drung (bdrung)
description: updated
Changed in apport:
milestone: none → 2.22.0
Benjamin Drung (bdrung)
description: updated
Benjamin Drung (bdrung)
Changed in apport (Ubuntu):
status: New → Triaged
Changed in apport:
status: New → Triaged
Benjamin Drung (bdrung)
Changed in apport (Ubuntu):
importance: Undecided → Medium
Changed in apport:
importance: Undecided → Medium
Revision history for this message
Benjamin Drung (bdrung) wrote :
Changed in apport:
status: Triaged → Fix Committed
Benjamin Drung (bdrung)
Changed in apport:
status: Fix Committed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

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

---------------
apport (2.22.0-0ubuntu1) kinetic; urgency=medium

  * New upstream release:
    - Replace `ProblemReport.get_date` by `ProblemReport.get_timestamp`, fixes
      regression in 2.21.0 (LP: #1978487)
    - apport-gtk: Exclude trailing dot from URL links (LP: #1978301)
    - Fix `AttributeError`: 'NoneType' object has no attribute 'write', fixes
      regression in 2.21.0 (LP: #1979211)
    - apport_python_hook: Properly handle missing modules (LP: #1774843)
    - apport_python_hook: Fix FileNotFoundError if the current directory was
      deleted (LP: #1979637)
    - apport_python_hook: Fix crash if os.getcwd() fails (LP: #1977954)
    - Replace deprecated 'imp' module (LP: #1947425)
    - whoopsie-upload-all: Fix 'EOFError' object has no attribute 'errno',
      fixes regression in 2.21.0 (LP: #1979681)
  * Fix KeyError: 'CasperMD5json'

 -- Benjamin Drung <email address hidden> Mon, 27 Jun 2022 12:03:00 +0200

Changed in apport (Ubuntu):
status: Triaged → Fix Released
Benjamin Drung (bdrung)
description: updated
Revision history for this message
Benjamin Drung (bdrung) wrote :

Since Ubuntu 21.10 (impish) will be end of life soon, we won't prepare a SRU for it.

Changed in apport (Ubuntu Impish):
status: New → Won't Fix
Benjamin Drung (bdrung)
Changed in apport (Ubuntu Focal):
status: New → Fix Committed
Changed in apport (Ubuntu Jammy):
status: New → Fix Committed
Benjamin Drung (bdrung)
Changed in apport:
importance: Medium → High
Changed in apport (Ubuntu):
importance: Medium → High
Benjamin Drung (bdrung)
description: updated
Revision history for this message
Steve Langasek (vorlon) wrote : Proposed package upload rejected

An upload of apport to jammy-proposed has been rejected from the upload queue for the following reason: "contains bugfixes without bug references or test cases, does not meet SRU policy".

Revision history for this message
Benjamin Drung (bdrung) wrote :

This crash has been fixed as drive-by fix for bug #1982555 in apport 2.20.11-0ubuntu27.25 (focal) and apport 2.20.11-0ubuntu82.2 (jammy).

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