Skip to content

apt_dpkg: discard cached contents mapping on OSError#593

Open
bdrung wants to merge 1 commit into
canonical:mainfrom
bdrung:fix-pickle-load
Open

apt_dpkg: discard cached contents mapping on OSError#593
bdrung wants to merge 1 commit into
canonical:mainfrom
bdrung:fix-pickle-load

Conversation

@bdrung

@bdrung bdrung commented Apr 22, 2026

Copy link
Copy Markdown
Member

test_retrace_jammy_sandbox might fail in a autopkgtest VM:

Traceback (most recent call last):
  File "/usr/bin/apport-retrace", line 713, in <module>
    sys.exit(main(sys.argv[1:]))
             ~~~~^^^^^^^^^^^^^^
  File "/usr/bin/apport-retrace", line 542, in main
    sandbox, cache, outdated_msg = apport.sandboxutils.make_sandbox(
                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        report,
        ^^^^^^^
    ...<6 lines>...
        options.dynamic_origins,
        ^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/lib/python3/dist-packages/apport/sandboxutils.py", line 274, in make_sandbox
    pkgs = needed_runtime_packages(report, pkgmap_cache_dir, pkg_versions, verbose)
  File "/usr/lib/python3/dist-packages/apport/sandboxutils.py", line 103, in needed_runtime_packages
    pkg = packaging.get_file_package(
        line,
    ...<3 lines>...
        arch=report.get("Architecture"),
    )
  File "/usr/lib/python3/dist-packages/apport/packaging_impl/apt_dpkg.py", line 800, in get_file_package
    return self._search_contents(file, map_cachedir, release, arch)
           ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/apport/packaging_impl/apt_dpkg.py", line 1752, in _search_contents
    contents_mapping = self._get_file2pkg_mapping(map_cachedir, release, arch)
  File "/usr/lib/python3/dist-packages/apport/packaging_impl/apt_dpkg.py", line 1726, in _get_file2pkg_mapping
    file2pkg = self._contents_mapping(map_cachedir, release, arch)
  File "/usr/lib/python3/dist-packages/apport/packaging_impl/apt_dpkg.py", line 340, in _contents_mapping
    self._contents_mapping_obj = pickle.load(fp)
                                 ~~~~~~~~~~~^^^^
EOFError: Ran out of input

Discard the cache in those cases and just rebuild them.

Bug: https://launchpad.net/bugs/2149911

@codecov

codecov Bot commented Apr 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.48%. Comparing base (713829f) to head (7179c4c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #593      +/-   ##
==========================================
+ Coverage   84.47%   84.48%   +0.01%     
==========================================
  Files         106      106              
  Lines       21053    21080      +27     
  Branches     3223     3227       +4     
==========================================
+ Hits        17784    17810      +26     
+ Misses       2793     2792       -1     
- Partials      476      478       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bdrung bdrung force-pushed the fix-pickle-load branch 3 times, most recently from 18f5f37 to 97ccb24 Compare April 22, 2026 19:05
@bdrung bdrung force-pushed the fix-pickle-load branch 2 times, most recently from 25c2475 to a1de7c2 Compare July 2, 2026 11:09
test_retrace_jammy_sandbox might fail in a autopkgtest VM:

```
Traceback (most recent call last):
  File "/usr/bin/apport-retrace", line 713, in <module>
    sys.exit(main(sys.argv[1:]))
             ~~~~^^^^^^^^^^^^^^
  File "/usr/bin/apport-retrace", line 542, in main
    sandbox, cache, outdated_msg = apport.sandboxutils.make_sandbox(
                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        report,
        ^^^^^^^
    ...<6 lines>...
        options.dynamic_origins,
        ^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/lib/python3/dist-packages/apport/sandboxutils.py", line 274, in make_sandbox
    pkgs = needed_runtime_packages(report, pkgmap_cache_dir, pkg_versions, verbose)
  File "/usr/lib/python3/dist-packages/apport/sandboxutils.py", line 103, in needed_runtime_packages
    pkg = packaging.get_file_package(
        line,
    ...<3 lines>...
        arch=report.get("Architecture"),
    )
  File "/usr/lib/python3/dist-packages/apport/packaging_impl/apt_dpkg.py", line 800, in get_file_package
    return self._search_contents(file, map_cachedir, release, arch)
           ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/apport/packaging_impl/apt_dpkg.py", line 1752, in _search_contents
    contents_mapping = self._get_file2pkg_mapping(map_cachedir, release, arch)
  File "/usr/lib/python3/dist-packages/apport/packaging_impl/apt_dpkg.py", line 1726, in _get_file2pkg_mapping
    file2pkg = self._contents_mapping(map_cachedir, release, arch)
  File "/usr/lib/python3/dist-packages/apport/packaging_impl/apt_dpkg.py", line 340, in _contents_mapping
    self._contents_mapping_obj = pickle.load(fp)
                                 ~~~~~~~~~~~^^^^
EOFError: Ran out of input
```

Discard the cache in those cases and just rebuild them.

Bug: https://launchpad.net/bugs/2149911
@bdrung bdrung force-pushed the fix-pickle-load branch from a1de7c2 to 7179c4c Compare July 2, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant