apport: FileNotFoundError in _add_executable_timestamp on ExecutablePath

Bug #2098792 reported by errors.ubuntu.com bug bridge
38
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Apport
Fix Released
High
Unassigned
apport (Ubuntu)
Fix Released
High
Unassigned
Jammy
New
Undecided
Unassigned
Noble
New
Undecided
Unassigned

Bug Description

[Original report]
```
Traceback (most recent call last):
  File "/usr/share/apport/apport", line 1253, in <module>
    sys.exit(main(sys.argv[1:]))
             ~~~~^^^^^^^^^^^^^^
  File "/usr/share/apport/apport", line 762, in main
    return process_crash_from_systemd_coredump(options.systemd_coredump_instance)
  File "/usr/share/apport/apport", line 1246, in process_crash_from_systemd_coredump
    report = apport.report.Report.from_systemd_coredump(coredump)
  File "/usr/lib/python3/dist-packages/apport/report.py", line 2082, in from_systemd_coredump
    report._add_executable_timestamp()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3/dist-packages/apport/report.py", line 815, in _add_executable_timestamp
    self["ExecutableTimestamp"] = str(int(os.stat(self["ExecutablePath"]).st_mtime))
                                          ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/.mount_jetbraMkhivj/jetbrains-toolbox'
```

The Ubuntu Error Tracker has been receiving reports about a problem regarding apport. This problem was most recently seen with package version 2.31.0-0ubuntu4, the problem page at https://errors.ubuntu.com/problem/de11995c45fc4b1c7cc769a55d31533f6f9d8b51 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/.

[ Impact ]

* This is bug #4 for noble: https://errors.ubuntu.com/?release=Ubuntu%2024.04&package=apport&period=month
* apport: FileNotFoundError in _add_executable_timestamp on ExecutablePath:

```
Traceback (most recent call last):
  File "/usr/share/apport/apport", line 1253, in <module>
    sys.exit(main(sys.argv[1:]))
             ~~~~^^^^^^^^^^^^^^
  File "/usr/share/apport/apport", line 762, in main
    return process_crash_from_systemd_coredump(options.systemd_coredump_instance)
  File "/usr/share/apport/apport", line 1246, in process_crash_from_systemd_coredump
    report = apport.report.Report.from_systemd_coredump(coredump)
  File "/usr/lib/python3/dist-packages/apport/report.py", line 2082, in from_systemd_coredump
    report._add_executable_timestamp()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3/dist-packages/apport/report.py", line 815, in _add_executable_timestamp
    self["ExecutableTimestamp"] = str(int(os.stat(self["ExecutablePath"]).st_mtime))
                                          ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/.mount_jetbraMkhivj/jetbrains-toolbox'
```

* The upload fixes the bug as https://github.com/canonical/apport/pull/538 adds a try-catch for FileNotFoundError and sets ExecutableTimestamp to an error message.

[ Test Plan ]

 * This crash can be reproduced with systemd-coredump installed:

```
cp /usr/bin/sleep /tmp/sleep
/tmp/sleep 3600
killall -11 sleep
```

This is caused by /usr/lib/systemd/system/apport-coredump-hook@.service having:

```
PrivateTmp=yes
```

 * https://github.com/canonical/apport/pull/538 also introduced a unit test for this.

[ Where problems could occur ]

 * We are modifying the conditions for checking if a binary has changed since the crash so a syntax error or a logical error in the condition can lead to buggy behavior.

 * Since apport is primarily for crash reports, user experience is unlikely to be affected much.

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

We should probably stat /proc/<pid>/exe because that even works on deleted executables.

description: updated
Benjamin Drung (bdrung)
tags: added: questing
Revision history for this message
Benjamin Drung (bdrung) wrote :

This one is reproducible with systemd-coredump installed:

```
cp /usr/bin/sleep /tmp/sleep
/tmp/sleep 3600
killall -11 sleep
```

This is caused by /usr/lib/systemd/system/apport-coredump-hook@.service having:

```
PrivateTmp=yes
```

Revision history for this message
Benjamin Drung (bdrung) wrote :
Changed in apport (Ubuntu):
importance: Undecided → High
status: New → In Progress
Changed in apport:
importance: Undecided → High
milestone: none → 2.34.0
status: New → In Progress
Revision history for this message
Benjamin Drung (bdrung) wrote :
Changed in apport:
status: In Progress → Fix Committed
Revision history for this message
Benjamin Drung (bdrung) wrote :
tags: added: noble
Benjamin Drung (bdrung)
tags: added: 24.04.1 oracular
Benjamin Drung (bdrung)
summary: - /usr/share/apport/apport:FileNotFoundError:/usr/share/apport/apport@1253:main:process_crash_from_systemd_coredump:from_systemd_coredump:_add_executable_timestamp
+ apport: FileNotFoundError in _add_executable_timestamp on ExecutablePath
description: updated
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.33.1-0ubuntu1

---------------
apport (2.33.1-0ubuntu1) questing; urgency=medium

  * New upstream release
    - report:
      + check for errors in ProcMaps in crash_signature_addresses (LP: #2114171)
      + Handle FileNotFoundError when determining ExecutableTimestamp
        (LP: #2098792)
    - apport: Do not hide FileNotFoundError during crash handling
    - test: use true from GNU coreutils (LP: #2111595)

 -- Benjamin Drung <email address hidden> Fri, 04 Jul 2025 21:40:18 +0200

Changed in apport (Ubuntu):
status: In Progress → 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.